Python and check if current datetime is in specific range -
i trying similar this, want specify start date , end date actual weekday names , times. example, want check if current datetime (datetime.datetime.now()) in between tuesday @ 4:30pm , thursday @ 11:45am. update weekly has tuesday/thursday mentality.
i have thought how weekdays (but don't know how wrap time part it):
timenow = datetime.datetime.now() if timenow.weekday() >= 1 , timenow.weekday() <= 3: #runcodehere
any thoughts on how this?
neatest way use amount of minutes elapsed in week:
def mins_in_week(day, hour, minute): return day * 24 * 60 + hour * 60 + minute if (mins_in_week(1, 16, 30) < mins_in_week(timenow.weekday(), timenow.hour, timenow.minute) < mins_in_week(3, 11, 45)): ....
Comments
Post a Comment