Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add localtime docs about timezones (inc. pitfalls) #182

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

benthorner
Copy link
Contributor

@benthorner benthorner commented Dec 18, 2024

@benthorner benthorner force-pushed the localtime/dst-warning branch 3 times, most recently from c636a5e to 7c21694 Compare December 18, 2024 12:35
@benthorner benthorner marked this pull request as ready for review December 18, 2024 12:39
@benthorner benthorner requested a review from jarshwah December 18, 2024 12:39
Copy link
Contributor

@jarshwah jarshwah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call outs, just unsure about two examples

# only one hour elapsed for the rest of the world.
localtime.as_utc(datetime(2020, 3, 29, hour=2, tzinfo=london_tz)) -
localtime.as_utc(datetime(2020, 3, 29, hour=0, tzinfo=london_tz))
=> timedelta(seconds=3600)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? This is showing 1 hour

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example is accurate, yes:

  • 2AM GBR => 1AM UTC
  • 0AM GBR => 0AM UTC

I've elaborated the comment a bit; does that help?

Comment on lines +64 to +71
datetime(2020, 3, 29, hour=2, tzinfo=london_tz) -
datetime(2020, 3, 29, hour=1, tzinfo=london_tz)
=> datetime.timedelta(seconds=3600) # <== WRONG (should be 0)
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section is confusing, it's not obvious why it's wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've elaborated the comment a bit; does that help?

Maybe this example just isn't a good fit here. I think it's important knowledge, so I'd like to put it somewhere.

@benthorner benthorner force-pushed the localtime/dst-warning branch from 7c21694 to 6b3363f Compare December 20, 2024 17:43
@benthorner benthorner requested a review from jarshwah December 20, 2024 17:46
@benthorner benthorner force-pushed the localtime/dst-warning branch from 6b3363f to 11a881e Compare December 20, 2024 17:51
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.

2 participants