Skip to content

Fix edge case for disambiguating ZonedDateTimes on DSTs skipping midnight #156

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

Merged
merged 1 commit into from
Jan 13, 2025

Conversation

jedel1043
Copy link
Member

Fixes part of the test intl402/Temporal/ZonedDateTime/from/dst-skipped-cross-midnight.js. This doesn't fix correctly resolving the start of the day for days that don't start at 00:00, since that'll require more advanced logic.

@jedel1043 jedel1043 added the C-bug Something isn't working label Jan 12, 2025
fn dst_skipped_cross_midnight() {
let provider = &FsTzdbProvider::default();
let midnight_disambiguated = ZonedDateTime::from_str_with_provider(
"1919-03-31T00[America/Toronto]",
Copy link
Member

Choose a reason for hiding this comment

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

Ah, shoot. Toronto 1919 🫠

@@ -557,14 +558,14 @@ impl TzProvider for FsTzdbProvider {
LocalTimeRecordResult::Empty => Vec::default(),
LocalTimeRecordResult::Single(r) => {
let epoch_ns =
EpochNanoseconds::try_from(epoch_nanos.0 + seconds_to_nanoseconds(r.offset))?;
EpochNanoseconds::try_from(epoch_nanos.0 - seconds_to_nanoseconds(r.offset))?;
Copy link
Member

Choose a reason for hiding this comment

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

Huh, is this correct? I think the tests below due assert that the time zones are not inverted like in PosixTzString, so I'm pretty sure the sign needs to be minus (I could definitely be off here). Ex: EST is -04:00, to move the local back to UTC you local - -04:00.

Copy link
Member Author

@jedel1043 jedel1043 Jan 13, 2025

Choose a reason for hiding this comment

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

Yes. The input is a local time, and the output is an UT. Hence, since local = UT + offset, then local - offset = UT

Copy link
Member

Choose a reason for hiding this comment

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

OH wait, I had put plus oh god 🤣

@nekevss nekevss merged commit 04cdeb3 into main Jan 13, 2025
5 checks passed
@jedel1043 jedel1043 deleted the dst-skipped-cross-midnight branch January 13, 2025 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants