-
Notifications
You must be signed in to change notification settings - Fork 543
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 from_timestamp_nanos #1357
Add from_timestamp_nanos #1357
Conversation
Add and implement from_timestamp_nanos and add unit test for it
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 0.4.x #1357 +/- ##
==========================================
+ Coverage 91.61% 91.64% +0.03%
==========================================
Files 38 38
Lines 17489 17553 +64
==========================================
+ Hits 16023 16087 +64
Misses 1466 1466 ☔ View full report in Codecov by Sentry. |
src/naive/datetime/mod.rs
Outdated
#[inline] | ||
#[must_use] | ||
pub const fn from_timestamp_nanos(nanos: i64) -> Option<NaiveDateTime> { | ||
let secs = nanos.div_euclid(1_000_000_000); |
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.
This should probably reuse the NANOS_PER_SEC
const
that we have defined somewhere.
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.
NANOS_PER_SEC
is in duration.rs mod and is inaccessible for me to use it, the solution is make them public for use
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.
NANOS_PER_SEC
will be pub
after #1351
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.
You can make it pub(crate)
for this change.
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.
So which one should i use for more compatibility with new commits?
- add
pub(crate)
induration.rs
or - make them
pub
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.
pub(crate)
, as said in my previous comment.
Thanks! |
Add and implement
from_timestamp_nanos
and add unit test for itKnown issue
if you input
i64::MAX
function give you a valid datetime, but fori64::MIN
it gives youNone
i think it's because time unit is nanoseconds
Thanks for contributing to chrono!
If your feature is semver-compatible, please target the 0.4.x branch;
the main branch will be used for 0.5.0 development going forward.
Please consider adding a test to ensure your bug fix/feature will not break in the future.