-
Notifications
You must be signed in to change notification settings - Fork 542
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
Deprecate timestamp methods on NaiveDateTime
#1473
Conversation
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.
Good stuff! Let's do a release soon after merging this so we can get some feedback?
934ce30
to
9a17072
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1473 /- ##
==========================================
- Coverage 92.16% 91.94% -0.22%
==========================================
Files 40 40
Lines 18052 18014 -38
==========================================
- Hits 16637 16563 -74
- Misses 1415 1451 36 ☔ View full report in Codecov by Sentry. |
932202f
to
1159dd9
Compare
Good idea, I'll start preparing release notes. Do we want to include #1450, deprecating the panicking constructors of |
Yes, that seems okay. |
`chrono::NaiveDateTime::from_timestamp_opt()` was deprecated in chronotope/chrono#1473. Prerequisite for #23272.
`chrono::NaiveDateTime::from_timestamp_opt()` was deprecated in chronotope/chrono#1473. Prerequisite for #23272.
`chrono::NaiveDateTime::from_timestamp_opt()` was deprecated in chronotope/chrono#1473. Prerequisite for denoland#23272.
As discussed in #1471 a timestamp is defined to be in UTC. The
NaiveDateTime
type doesn't know the offset from UTC, so is is technically wrong to have these methods. Users should use the similar methods on theDateTime<Utc>
type (or theTimeZone
trait) instead.Converting from
NaiveDateTime
toDateTime<Utc>
is simple with.and_utc()
, and in the other direction with.naive_utc()
.The first commit introduces two extra functions on
DateTime<Utc>
to get feature parity withNaiveDateTime
:from_timestamp_micros
andfrom_timestamp_nanos
.Later commits move over our implementation and tests from
NaiveDateTime
toDateTime
.Then we avoid using the timestamp methods on
NaiveDateTime
and deprecate the them.