Skip to content

Commit 048fa87

Browse files
Normalize naive datetimes to UTC in parse_watch_expiration
When parse_rfc3339 returns a naive datetime (no timezone info), explicitly set tzinfo to UTC before calling timestamp(). This ensures consistent behavior regardless of server timezone and matches the pattern used in format_rfc3339. Co-authored-by: Hubert <hubert-marek@users.noreply.github.com>
1 parent 0550cc8 commit 048fa87

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

backend/src/services/calendar/api/methods.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import json
1111
import logging
12+
from datetime import timezone
1213
from typing import Any, Callable, Awaitable, Optional
1314
from functools import wraps
1415

@@ -152,6 +153,9 @@ def parse_watch_expiration(expiration: Any) -> Optional[int]:
152153
# Try parsing as ISO date string
153154
try:
154155
dt = parse_rfc3339(expiration)
156+
# If datetime is naive, assume UTC
157+
if dt.tzinfo is None:
158+
dt = dt.replace(tzinfo=timezone.utc)
155159
# Convert to milliseconds since epoch
156160
return int(dt.timestamp() * 1000)
157161
except (ValueError, AttributeError):

0 commit comments

Comments
 (0)