File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -350,14 +350,21 @@ def setDatetimeTimezone(value):
350350 # Use local timezone if value is True or "local"
351351 elif value is True or (isinstance (value , str ) and value .strip ().lower () == 'local' ):
352352 tzinfo = datetime .now ().astimezone ().tzinfo
353- # Attempt to resolve value as an IANA timezone string
353+ # Attempt to resolve value as an IANA timezone string or boolean-like string
354354 else :
355355 setting = str (value ).strip ()
356- try :
357- tzinfo = ZoneInfo (setting )
358- except ZoneInfoNotFoundError :
356+ lower = setting .lower ()
357+ # Handle common boolean-like strings from config/environment
358+ if lower in ('true' , '1' ):
359+ tzinfo = datetime .now ().astimezone ().tzinfo
360+ elif lower in ('false' , '0' ):
359361 tzinfo = None
360- log .warning ('Failed to set timezone to "%s", defaulting to None' , value )
362+ else :
363+ try :
364+ tzinfo = ZoneInfo (setting )
365+ except ZoneInfoNotFoundError :
366+ tzinfo = None
367+ log .warning ('Failed to set timezone to "%s", defaulting to None' , value )
361368
362369 DATETIME_TIMEZONE = tzinfo
363370 return DATETIME_TIMEZONE
You can’t perform that action at this time.
0 commit comments