From b207c9e2416114d61873eccc32877558fa52c403 Mon Sep 17 00:00:00 2001 From: altaf-creator Date: Mon, 29 Dec 2025 23:38:21 +0800 Subject: timezones --- backend/main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'backend') diff --git a/backend/main.py b/backend/main.py index 00cbd8c..028fbfa 100644 --- a/backend/main.py +++ b/backend/main.py @@ -142,6 +142,7 @@ URI_TO_MACHINES = { "h2-washer2": [2, 4], } +TZ = "+07:00" # ## global vars for user-end @@ -295,9 +296,9 @@ def start_new_timer(data: RequestData, response: fastapi.Response, session_key: end_date = now + datetime.timedelta(minutes=(data.duration * 30)) cursor.execute(""" INSERT INTO timers (user_id, start_time, end_time, block, machine, status, subscription_id) - VALUES (?, ?, ?, ?, ?, ?, ?)""", (session_key, now.isoformat(), end_date.isoformat(), block, machine, 'RUNNING', subscription_endpoint,)) + VALUES (?, ?, ?, ?, ?, ?, ?)""", (session_key, now.isoformat() + TZ, end_date.isoformat() + TZ, block, machine, 'RUNNING', subscription_endpoint,)) conn.commit() - cursor.execute("SELECT * FROM timers WHERE end_time = ?;", (end_date.isoformat(),)) + cursor.execute("SELECT * FROM timers WHERE end_time = ?;", (end_date.isoformat() + TZ,)) out = cursor.fetchall() for row in out: @@ -320,7 +321,7 @@ def start_new_timer(data: RequestData, response: fastapi.Response, session_key: try: machine_status[block - 1][machine - 1] = Status.RUNNING.name - machine_times[block - 1][machine - 1] = now.isoformat() + machine_times[block - 1][machine - 1] = now.isoformat() + TZ machine_endings[block - 1][machine - 1] = end_date except Exception as exception: print("err @ machine_status //", exception) -- cgit v1.2.3