Skip to content
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 timestamp_nanos_opt, deprecate timestamp_nanos #1275

Merged
merged 6 commits into from
Sep 12, 2023

Conversation

pitdicker
Copy link
Collaborator

NaiveDateTime::timestamp_nanos and DateTime::timestamp_nanos are two of the few methods that can panic on somewhat reasonable values and have no alternative that returns Option.

I added timestamp_nanos_opt and went ahead and deprecated the the old methods, like all other fallible methods.

The new method lead to a nice little simplification in duration_round and duration_trunc.

@codecov
Copy link

codecov bot commented Sep 8, 2023

Codecov Report

Merging #1275 (7d20d22) into 0.4.x (77d0bec) will decrease coverage by 0.03%.
Report is 6 commits behind head on 0.4.x.
The diff coverage is 88.23%.

@@            Coverage Diff             @@
##            0.4.x    #1275      +/-   ##
==========================================
- Coverage   91.40%   91.37%   -0.03%     
==========================================
  Files          38       38              
  Lines       16932    16957      +25     
==========================================
+ Hits        15477    15495      +18     
- Misses       1455     1462       +7     
Files Changed Coverage Δ
src/naive/datetime/mod.rs 97.34% <42.85%> (-0.37%) ⬇️
src/datetime/mod.rs 86.08% <100.00%> (-0.15%) ⬇️
src/datetime/serde.rs 87.56% <100.00%> (+0.06%) ⬆️
src/naive/datetime/serde.rs 85.65% <100.00%> (+0.08%) ⬆️
src/naive/datetime/tests.rs 98.63% <100.00%> (-0.03%) ⬇️
src/round.rs 97.72% <100.00%> (+0.14%) ⬆️

... and 3 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@pitdicker pitdicker force-pushed the deprecate_timestamp_nanos branch from 35e6ac5 to 0ff33d3 Compare September 8, 2023 20:29
@@ -180,7 +188,10 @@ pub mod ts_nanoseconds {
where
S: ser::Serializer,
{
serializer.serialize_i64(dt.timestamp_nanos())
serializer.serialize_i64(
Copy link
Member

Choose a reason for hiding this comment

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

For all of these, why not yield errors here?

(Let's not have a . in expect() messages.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, they should just return an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants