-
Notifications
You must be signed in to change notification settings - Fork 532
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
Remove check for DurationExceedsTimestamp #1403
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1403 +/- ##
=======================================
Coverage 91.85% 91.86%
=======================================
Files 38 38
Lines 17526 17531 +5
=======================================
+ Hits 16098 16104 +6
+ Misses 1428 1427 -1 ☔ View full report in Codecov by Sentry. |
Thank you @joroKr21. I'll have to think this through. |
8bbeaaf
to
23f4944
Compare
@@ -220,9 +217,6 @@ where | |||
return Err(RoundingError::DurationExceedsLimit); | |||
} | |||
let stamp = naive.timestamp_nanos_opt().ok_or(RoundingError::TimestampExceedsLimit)?; | |||
if span > stamp.abs() { | |||
return Err(RoundingError::DurationExceedsTimestamp); | |||
} |
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.
Removing this check seems fine to me.
@@ -181,9 +181,6 @@ where | |||
return Err(RoundingError::DurationExceedsLimit); | |||
} | |||
let stamp = naive.timestamp_nanos_opt().ok_or(RoundingError::TimestampExceedsLimit)?; | |||
if span > stamp.abs() { | |||
return Err(RoundingError::DurationExceedsTimestamp); | |||
} |
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.
If you remove this check, I expect it will introduce a panic if the date is large and the duration is even larger. Say a date in the year 200.000 and rounding to a duration of 300.000 years.
Could you add a test for this case, and do something to avoid the panic?
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.
We can't really work with such big timestamps here. It will return a TimestampExceedsLimit
error:
An i64 with nanosecond precision can span a range of ~584 years. This function returns None on an out of range NaiveDateTime.
The dates that can be represented as nanoseconds are between 1677-09-21T00:12:43.145224192 and 2262-04-11T23:47:16.854775807.
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.
Sorry, that's what I get when writing this without testing 😄. Any other errors with large durations such as 400 years that the previous check would have protected against?
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.
I couldn't find any. Added a test for timestamps that are close to the min / max of nanosecond precision
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.
Thank you 👍. @djc will also want to have a look, but it seems good to merge for me.
5d0bbfe
to
377fe51
Compare
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.
Just needs a rebase.
This check is not necessary and prevented rounding and truncation from working correctly on timestamps close to the Unix epoch.
377fe51
to
ac28866
Compare
Looks like CI is failing on something unrelated |
All CI failures are with the reason:
Curious. In any case unrelated to your work. |
We don't seem to be the only one thin-edge/thin-edge.io#2687. |
Rkyv seems in the process of updating to hashbrown 0.14 (rkyv/rkyv@7b88320). Hashbrown 0.14 uses the updated ahash 0.8, which should build on the current nightly. Once a new version of rkyv is released our CI should be green again. cc @djkoloski |
rkyv 0.7 will not be updating to a newer version of hashbrown because it would be a server breaking change. 0.8 won't be out for a while either. I did create a branch of 0.7 that updates hashbrown yesterday ( |
There's also a PR to request an update to ahash 0.7: tkaitchuck/aHash#201. |
Thank you for the explanation and replying here.
Nice, that seems to be the easier fix. |
This check is not necessary and prevented rounding and truncation from working correctly on timestamps close to the Unix epoch.
fixes #1375
Thanks for contributing to chrono!
If your feature is semver-compatible, please target the main branch;
for semver-incompatible changes, please target the
0.5.x
branch.Please consider adding a test to ensure your bug fix/feature will not break in the future.