Skip to content

Commit 4ee2116

Browse files
eliasbenbCopilot
andauthored
fix: bool-like parsing in setDatetimeTimezone resolution
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent c71faba commit 4ee2116

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

plexapi/utils.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)