mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-11 21:33:00 +00:00
fix: correct timezone handling in calendar event display
This commit is contained in:
@@ -245,17 +245,18 @@ class CalendarManager:
|
|||||||
try:
|
try:
|
||||||
# Handle both date and dateTime formats
|
# Handle both date and dateTime formats
|
||||||
if 'T' in start:
|
if 'T' in start:
|
||||||
dt = datetime.fromisoformat(start.replace('Z', '+00:00'))
|
# The datetime string already includes timezone info (-05:00)
|
||||||
logger.debug(f"Parsed datetime from event: {dt} (UTC)")
|
dt = datetime.fromisoformat(start)
|
||||||
|
logger.debug(f"Parsed datetime from event: {dt}")
|
||||||
else:
|
else:
|
||||||
dt = datetime.strptime(start, '%Y-%m-%d')
|
dt = datetime.strptime(start, '%Y-%m-%d')
|
||||||
# Make date object timezone-aware (assume UTC if no tz info)
|
# Make date object timezone-aware (assume UTC if no tz info)
|
||||||
dt = pytz.utc.localize(dt)
|
dt = pytz.utc.localize(dt)
|
||||||
logger.debug(f"Parsed date from event: {dt} (UTC)")
|
logger.debug(f"Parsed date from event: {dt}")
|
||||||
|
|
||||||
local_dt = dt.astimezone(self.timezone) # Use configured timezone
|
# No need to convert timezone since it's already in the correct one
|
||||||
logger.debug(f"Converted to local timezone: {local_dt} ({self.timezone})")
|
logger.debug(f"Using event timezone: {dt}")
|
||||||
return local_dt.strftime("%a %-m/%-d") # e.g., "Mon 4/21"
|
return dt.strftime("%a %-m/%-d") # e.g., "Mon 4/21"
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
logging.error(f"Could not parse date string: {start} - {e}")
|
logging.error(f"Could not parse date string: {start} - {e}")
|
||||||
return ""
|
return ""
|
||||||
@@ -267,11 +268,12 @@ class CalendarManager:
|
|||||||
return "All Day"
|
return "All Day"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dt = datetime.fromisoformat(start.replace('Z', '+00:00'))
|
# The datetime string already includes timezone info (-05:00)
|
||||||
logger.debug(f"Parsed time from event: {dt} (UTC)")
|
dt = datetime.fromisoformat(start)
|
||||||
local_dt = dt.astimezone(self.timezone) # Use configured timezone
|
logger.debug(f"Parsed time from event: {dt}")
|
||||||
logger.debug(f"Converted to local timezone: {local_dt} ({self.timezone})")
|
# No need to convert timezone since it's already in the correct one
|
||||||
return local_dt.strftime("%I:%M %p")
|
logger.debug(f"Using event timezone: {dt}")
|
||||||
|
return dt.strftime("%I:%M %p")
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
logging.error(f"Could not parse time string: {start} - {e}")
|
logging.error(f"Could not parse time string: {start} - {e}")
|
||||||
return "Invalid Time"
|
return "Invalid Time"
|
||||||
|
|||||||
Reference in New Issue
Block a user