File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -209,10 +209,13 @@ def format_date_iso(date_val: str) -> Optional[str]:
209209 # 2. If it has no timezone, assume it's UTC (our DB storage format)
210210 # then CONVERT to user's configured timezone
211211 if dt .tzinfo is None :
212- # Mark as UTC first
212+ # Mark as UTC first — critical: localize() would label without converting
213213 dt = dt .replace (tzinfo = datetime .UTC )
214- # Convert to user's timezone
215- target_tz = conf .tz if isinstance (conf .tz , datetime .tzinfo ) else ZoneInfo (conf .tz )
214+ # Resolve target timezone; fall back to UTC if conf.tz is missing/invalid
215+ try :
216+ target_tz = conf .tz if isinstance (conf .tz , datetime .tzinfo ) else ZoneInfo (conf .tz )
217+ except Exception :
218+ target_tz = datetime .UTC
216219 dt = dt .astimezone (target_tz )
217220
218221 # 3. Return the string. .isoformat() will now include the +11:00 or +10:00
You can’t perform that action at this time.
0 commit comments