Skip to content

fix(code): Return timezone-aware UTC datetimes from TemporarySchedule#405

Open
dknowles2 wants to merge 1 commit into
mainfrom
fix/issue-355
Open

fix(code): Return timezone-aware UTC datetimes from TemporarySchedule#405
dknowles2 wants to merge 1 commit into
mainfrom
fix/issue-355

Conversation

@dknowles2

Copy link
Copy Markdown
Owner

Fixes #355

Previously, TemporarySchedule.from_json() used datetime.fromtimestamp() without a timezone argument, which converts the Unix timestamp to the local timezone of the host as a naive datetime. This could lead to confusing results when the server's timezone differs from the user's expected timezone.

Now, datetimes are returned as timezone-aware UTC datetimes, which are unambiguous and consistent with the rest of the library (e.g. Notification already uses UTC-aware datetimes via fromisoformat).

Changes

  • TemporarySchedule.from_json(): pass tz=UTC to datetime.fromtimestamp()
  • Updated test to use UTC-aware expected datetimes

Fixes #355

Previously, TemporarySchedule.from_json() used datetime.fromtimestamp()
without a timezone argument, which converts the Unix timestamp to the
local timezone of the host as a naive datetime. This could lead to
confusing results when the server timezone differs from the user's
expected timezone.

Now, datetimes are returned as timezone-aware UTC datetimes, which is
unambiguous and consistent with the rest of the library (e.g. Notification
uses UTC-aware datetimes via fromisoformat).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Timezone issues

1 participant