From 6030dc04f962615dedb6eadd45013477db233efd Mon Sep 17 00:00:00 2001 From: Peter Howell Date: Fri, 29 Aug 2025 23:32:03 +0000 Subject: [PATCH] gpt --- localcache2.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/localcache2.py b/localcache2.py index 0b29098..2849397 100644 --- a/localcache2.py +++ b/localcache2.py @@ -822,6 +822,17 @@ def insert_usefulinfo_record(parsed): except Exception as ex_dt: print("[usefulinfo][event-parse] bad dt:", dt_str, "error:", str(ex_dt)) + # Normalize DT string for storage + normalized_dt = dt_str + try: + if parsed_ok: + if all_day: + normalized_dt = p.date().isoformat() # YYYY-MM-DD + else: + normalized_dt = p.strftime('%Y-%m-%dT%H:%M:%S') # ISO without TZ + except Exception as ex_norm: + print("[usefulinfo][event-dt-normalize-failed] dt_str=", dt_str, " error=", str(ex_norm)) + def _mins(s): if not s: return 60 @@ -853,7 +864,7 @@ def insert_usefulinfo_record(parsed): VALUES (%s, %s, %s, %s, %s) RETURNING id """, - (summary_id, raw_dt, raw_len, raw_title, raw_desc) + (summary_id, normalized_dt, raw_len, raw_title, raw_desc) ) else: CUR.execute( @@ -862,7 +873,7 @@ def insert_usefulinfo_record(parsed): VALUES (%s, %s, %s, %s) RETURNING id """, - (raw_dt, raw_len, raw_title, raw_desc) + (normalized_dt, raw_len, raw_title, raw_desc) ) evrow = CUR.fetchone() if evrow and evrow[0]: