From 8e51eebf26e899a4800cdad9b1f447b712b47312 Mon Sep 17 00:00:00 2001 From: zay <64491586+zaytiri@users.noreply.github.com> Date: Sun, 26 Mar 2023 11:41:57 +0100 Subject: [PATCH] fix date time utcnow() to just now() using utcnow() means it does not give the date of the device and if the date changes on the device, the scheduled jobs won't run; --- progscheduler/app.py | 2 +- progscheduler/jobs.py | 2 +- progscheduler/scheduler.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/progscheduler/app.py b/progscheduler/app.py index 82c8b75..e33c4d8 100644 --- a/progscheduler/app.py +++ b/progscheduler/app.py @@ -41,7 +41,7 @@ def is_time_to_stop_valid(program_name, time_to_stop): def is_scheduled_today(days_to_schedule): - now = datetime.utcnow() + now = datetime.now() return now.strftime("%A").lower() in days_to_schedule diff --git a/progscheduler/jobs.py b/progscheduler/jobs.py index d13de2b..8be41d4 100644 --- a/progscheduler/jobs.py +++ b/progscheduler/jobs.py @@ -5,7 +5,7 @@ def open_program(root_path): - now = datetime.utcnow() + now = datetime.now() os.startfile(root_path) show('The following file \n\t\t\t\'' + root_path + '\'\n\t\t has started at ' + str(now.hour).zfill(2) + ':' + str(now.minute).zfill(2) + ':' + str( now.second).zfill(2) + '.') diff --git a/progscheduler/scheduler.py b/progscheduler/scheduler.py index 33dce0e..6ad925a 100644 --- a/progscheduler/scheduler.py +++ b/progscheduler/scheduler.py @@ -101,5 +101,5 @@ def __schedule_method(self, time_to_schedule, day='everyday'): def __get_now_date(self): self.__seconds_delay += 1 - now = datetime.utcnow() + timedelta(seconds=self.__seconds_delay) + now = datetime.now() + timedelta(seconds=self.__seconds_delay) return str(now.hour).zfill(2) + ':' + str(now.minute).zfill(2) + ':' + str(now.second).zfill(2)