Skip to content

Commit 2bf030e

Browse files
committed
Use utcoffset() to detect truly-aware timer fire_at (PR review)
1 parent a6cf7e8 commit 2bf030e

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

durabletask/worker.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1675,7 +1675,10 @@ def create_timer_internal(
16751675

16761676
# Normalize timezone-aware datetimes to naive UTC so they can be safely
16771677
# compared against and combined with the orchestration's naive UTC clock.
1678-
if final_fire_at.tzinfo is not None:
1678+
# A datetime is only truly aware when utcoffset() returns a value; a
1679+
# tzinfo whose utcoffset() is None is still naive and must be left as-is
1680+
# (calling astimezone() on it would raise ValueError).
1681+
if final_fire_at.utcoffset() is not None:
16791682
final_fire_at = final_fire_at.astimezone(timezone.utc).replace(tzinfo=None)
16801683

16811684
next_fire_at: datetime = final_fire_at

0 commit comments

Comments
 (0)