Remote utc to localtime conversion from daily_plot.py
Introduction of yesterday/today handling added a bug that expresses itself on systems whose timezones are behind UTC. Specifically, the 'localtime' modifier to DATE() attempts to interpret the date to the left as UTC, and convert to localtime. The result is that in timezones behind UTC, the date selected is always 1 earlier than intended.
No timezone conversion should be done. The db data is in local time already.
Here's a demonstration of calling DATE() in various ways in North America EST:
sqlite> select DATE('now');
2024-02-26
sqlite> select DATETIME('now');
2024-02-26 17:20:46
sqlite> select DATE('2024-02-26');
2024-02-26
sqlite> select DATETIME('2024-02-26');
2024-02-26 00:00:00
sqlite> select DATE('now', 'localtime');
2024-02-26
sqlite> select DATE('2024-02-26', 'localtime');
2024-02-25 <--- this is the bug
This commit is contained in:
@@ -19,7 +19,7 @@ def get_data(now=None):
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
if now is None:
|
||||
now = datetime.now()
|
||||
df = pd.read_sql_query(f"SELECT * from detections WHERE Date = DATE('{now.strftime('%Y-%m-%d')}', 'localtime')",
|
||||
df = pd.read_sql_query(f"SELECT * from detections WHERE Date = DATE('{now.strftime('%Y-%m-%d')}')",
|
||||
conn)
|
||||
|
||||
# Convert Date and Time Fields to Panda's format
|
||||
|
||||
Reference in New Issue
Block a user