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 DateTime::<Utc>::from_timestamp #1279

Merged
merged 1 commit into from Sep 11, 2023

Conversation

demurgos
Copy link
Contributor

This commit adds the new constructor from_timestamp to build a DateTime<Utc> from a UNIX timestamp.

Figuring out how to convert a timestamp into a DateTime<Utc> was a common issue:

This commit should make DateTime<Utc> creation more discoverable and intuitive.

This commit respects the current convention of preferring fallible functions. It avoids however the _opt suffix as there is no panicking variant. See this issue for discussion about error handling and panics.

This commit adds the new constructor `from_timestamp` to build a `DateTime<Utc>` from a UNIX timestamp.

Figuring out how to convert a timestamp into a `DateTime<Utc>` was a common issue:
- chronotope#88
- chronotope#200
- chronotope#832

This commit should make `DateTime<Utc>` creation more discoverable and intuitive.

This commit respects the current convention of preferring fallible functions. It avoids however the `_opt` suffix as there is no panicking variant. See [this issue](chronotope#815) for discussion about error handling and panics.

Closes chronotope#832
@codecov
Copy link

codecov bot commented Sep 10, 2023

Codecov Report

Merging #1279 (449d907) into 0.4.x (2960f2c) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##            0.4.x    #1279   +/-   ##
=======================================
  Coverage   91.40%   91.41%           
=======================================
  Files          38       38           
  Lines       16932    16950   +18     
=======================================
+ Hits        15477    15495   +18     
  Misses       1455     1455           
Files Changed Coverage Δ
src/datetime/mod.rs 86.61% <100.00%> (+0.38%) ⬆️
src/lib.rs 95.58% <100.00%> (ø)

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

@djc djc merged commit ccd3737 into chronotope:0.4.x Sep 11, 2023
37 checks passed
@djc
Copy link
Contributor

djc commented Sep 11, 2023

Thanks!

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.

None yet

3 participants