I am trying to create an alarm/schedule based timeclock from a string that I get returned from a Telit HE910 modem. The AT command is AT+CCLK and the string result is: +CCLK: "2015/03/26,14:23:22+40". I have broken the string down into a time stamp of variables containing - YYYY - year / MM - month / DD - day / hh - hour / mm - minute / ss - seconds / ampm - AM or PM. All variables are strings and numeric types can safely float(mm) etc. The problem I am having is I'm not sure how to compare the minutes if my program is off doing another part of the program and it misses the exact minute as per the code below. Can anyone enlighten an easier way of doing this so that minutes can be compared plus 5 minutes in case the system is elsewhere especially if the alarm set time is XX hours 59 minutes. (Another part of the system could hold the program from seeing this code for 5 minutes or so)
def alarm_function(Time, Alarm): # Time Dictionary, Alarm Dictionary
if Time['ampm'] == Alarm['ampm']:
if Time['hh'] == Alarm['hh']:
if float(Time['mm']) == ((float(Alarm['mm']) or (float(Alarm['mm'] + 1) or (float(Alarm['mm'] + 2) or (float(Alarm['mm'] + 3) or (float(Alarm['mm'] + 4) or (float(Alarm['mm'] + 5)):
return True
return False
Minute comparison for visual expression only...