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 time zone timestamp micros #1285

Merged
merged 2 commits into from Sep 13, 2023

Conversation

emikitas
Copy link
Contributor

@emikitas emikitas commented Sep 12, 2023

I added TimeZone::timestamp_micros_opt and made TimeZone::timestamp_millis_opt use NaiveDateTime::from_timestamp_millis to reduce logic duplication.
resolves #1284

NaiveDateTime::from_timestamp_millis to reduce code duplication
@codecov
Copy link

codecov bot commented Sep 12, 2023

Codecov Report

Merging #1285 (81708eb) into main (21f9ccc) will decrease coverage by 0.01%.
The diff coverage is 92.00%.

@@            Coverage Diff             @@
##             main    #1285      +/-   ##
==========================================
- Coverage   91.49%   91.48%   -0.01%     
==========================================
  Files          35       35              
  Lines       16841    16860      +19     
==========================================
+ Hits        15408    15425      +17     
- Misses       1433     1435       +2     
Files Changed Coverage Δ
src/offset/mod.rs 53.68% <92.00%> (+3.02%) ⬆️

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

}

#[test]
fn test_micros_example() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think you need to copy the doctest here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I wasn't aware this gets tested automatically :)

///
/// assert_eq!(Utc.timestamp_micros_opt(1431648000000).unwrap().timestamp(), 1431648);
/// ```
fn timestamp_micros_opt(&self, micros: i64) -> LocalResult<DateTime<Self>> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this also use NaiveTime::from_timestamp_micros?

@djc Do we want the _opt suffix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tested using NaiveTime::from_timestamp_micros locally, it seems to work as expected.
Once we decide if you'll rather not have the _opt suffix, I'll push my changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's skip the opt suffix!

Copy link
Collaborator

@pitdicker pitdicker left a comment

Choose a reason for hiding this comment

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

Maybe squash the last two commits?

Use NaiveDateTime::from_timestamp_micros instead of implementing
the same logic again.
@pitdicker pitdicker merged commit b64cedc into chronotope:main Sep 13, 2023
37 checks passed
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.

Add timestamp_micros to Utc
3 participants