Fixed time problem

This commit is contained in:
Tim Staat 2025-08-29 16:24:55 +02:00
parent 363c791ef1
commit ce2f21d4a6

View File

@ -55,7 +55,7 @@ def getGpsDistance():
with sqlite3.connect('location.db', check_same_thread=False) as conn:
timezone = None
time = None
rTime = None
cur = conn.cursor()
try:
@ -64,12 +64,12 @@ def getGpsDistance():
if row:
req_lat, req_long, req_dateTime, insertDateTime = row
time = datetime.fromisoformat(req_dateTime)
rTime = datetime.fromisoformat(req_dateTime)
else:
req_lat = 0.0
req_long = 0.0
req_dateTime = datetime.now()
time = datetime.now()
rTime = datetime.now()
except sqlite3.Error as error:
print("Failed to read data from table, using default values", error)
@ -95,18 +95,18 @@ def getGpsDistance():
else:
print(timezone_str)
print(pytz.timezone(timezone_str))
time = time.replace(tzinfo=dttz.utc).astimezone(pytz.timezone(timezone_str))
rTime = rTime.replace(tzinfo=dttz.utc).astimezone(pytz.timezone(timezone_str))
print(time)
print(rTime)
else:
prettyDistance = "No GPS Signal"
fwd_azimuth = 0.0
time = datetime.utcnow
rTime = datetime.utcnow
return jsonify({'distance': prettyDistance, 'azimuth': fwd_azimuth, 'lastUpdateTZ': time.strftime("%H:%M:%S")})
return jsonify({'distance': prettyDistance, 'azimuth': fwd_azimuth, 'lastUpdateTZ': rTime.strftime("%H:%M:%S")})