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. |
| #[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.
This should probably reuse the NANOS_PER_SEC const that we have defined somewhere.
There was a problem hiding this comment.
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.
You can make it pub(crate) for this change.
There was a problem hiding this comment.
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.
pub(crate), as said in my previous comment.
|
Thanks! |
Add and implement
from_timestamp_nanosand add unit test for itKnown issue
if you input
i64::MAXfunction give you a valid datetime, but fori64::MINit gives youNonei 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.