-
Notifications
You must be signed in to change notification settings - Fork 19
Fix edge case for disambiguating ZonedDateTime
s 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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,7 +92,7 @@ impl From<LocalTimeTypeRecord> for LocalTimeRecord { | |
|
||
// TODO: Workshop record name? | ||
/// The `LocalTimeRecord` result represents the result of searching for a | ||
/// a for a time zone transition without the offset seconds applied to the | ||
/// time zone transition without the offset seconds applied to the | ||
/// epoch seconds. | ||
/// | ||
/// As a result of the search, it is possible for the resulting search to be either | ||
|
@@ -295,7 +295,8 @@ impl Tzif { | |
match offset_range.contains(¤t_diff.0) { | ||
true if next_record.is_dst => Ok(LocalTimeRecordResult::Empty), | ||
true => Ok((next_record, initial_record).into()), | ||
false => Ok(initial_record.into()), | ||
false if current_diff <= initial_record.utoff => Ok(initial_record.into()), | ||
false => Ok(next_record.into()), | ||
} | ||
} | ||
} | ||
|
@@ -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))?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OH wait, I had put plus oh god 🤣 |
||
vec![epoch_ns] | ||
} | ||
LocalTimeRecordResult::Ambiguous { std, dst } => { | ||
let std_epoch_ns = | ||
EpochNanoseconds::try_from(epoch_nanos.0 + seconds_to_nanoseconds(std.offset))?; | ||
EpochNanoseconds::try_from(epoch_nanos.0 - seconds_to_nanoseconds(std.offset))?; | ||
let dst_epoch_ns = | ||
EpochNanoseconds::try_from(epoch_nanos.0 + seconds_to_nanoseconds(dst.offset))?; | ||
EpochNanoseconds::try_from(epoch_nanos.0 - seconds_to_nanoseconds(dst.offset))?; | ||
vec![std_epoch_ns, dst_epoch_ns] | ||
} | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, shoot. Toronto 1919 🫠