Introduction to AlarmTime Module in Python

Alarm Time is a python module in python which is used to play with the date and time, using default datetime module of python. A date in Python is not a data type of its own, but we can import a module named datetime to work with dates as date objects. It has functions for finding difference between the dates in days or hours or seconds. This module is able to find the dates from the string text, like mentioning date for next 10 days in string format.
Installation:
pip install AlarmTime
Methods (Major Functions):
DateTimeDetect : It detects the date from the string
hour_diff_from_now : It gives difference between dates in hours
millisecond_diff_from_now: It gives difference between dates in milliseconds
minute_diff_from_now : It gives difference between dates in minutes
second_diff_from_now : It gives difference between dates in seconds
Example 1:
In this example, we will create a detectdate object to print the dates
Python3
# import the detectdate class from alarmtime modulefrom AlarmTime.AlarmTime import DetectDate# create a detectdate object for current date & time# by passing parameter as 0 will give current date & timecurrent = DetectDate(0)# printing the current date&time# now attribute for date&timeprint(current.now)# creating another detectdate object# passing 1 as argument i.e 1second after default dateanother = DetectDate(1)# printing date & time of another variableprint(another.now)# creating another detectdate object# after 1570010023345 secondsanother2 = DetectDate(1570010023345)# printing date & timeprint(another2.now) |
Output :
Example 2:
Here we will use various major functions with the DetectDate object.
Python3
# import the detectdate class from alarmtime modulefrom AlarmTime.AlarmTime import DetectDate# creatingdetectdate object# after 1570010023345 secondsfirst_date = DetectDate(1570010023345)# create a detectdate object for current date & time# by passing parameter as 0 will give current date & timecurrent = DetectDate(0)# getting two dates difference in secondsseconds = current.second_diff_from_now("after 10 days")# printing the seconds valueprint("Seconds Difference : " + str(seconds))# detecting the date & time using stringtarget_time = current.DateTimeDetect( 'detect the time and date on October 10 10 p.m')# printing the detected dateprint("Detected date : " + str(target_time))# detecting date after some timetarget_time2 = current.DateTimeDetect( 'after 6 month 500 days 10 hours 15 minutes')# printing the detected date & timeprint("Detected date after some time : " + str(target_time2)) |
Output :




