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

Deprecate all timestamp-related methods on NaiveDateTime #1471

Closed
pitdicker opened this issue Feb 28, 2024 · 1 comment
Closed

Deprecate all timestamp-related methods on NaiveDateTime #1471

pitdicker opened this issue Feb 28, 2024 · 1 comment

Comments

@pitdicker
Copy link
Collaborator

pitdicker commented Feb 28, 2024

The definition of a timestamp is that it is a value in UTC.
We don't know how a NaiveDateTime relates to UTC. So having methods on this type to convert to and from timestamps is in theory not correct.

The time crate chooses to not have any timestamp related methods on its PrimitiveDateTime for this reason.

Workarounds are not that problematic.
If the NaiveDate is in UTC dt.timestamp() would become dt.and_utc().timestamp().
NaiveDate::from_timestamp(ts, 0) would become Utc.timestamp(ts, 0).naive_utc().

Deprecating these methods can help users notice invalid assumptions, and removes 13 methods from our API surface.

@pitdicker pitdicker changed the title Deprecated all timestamp-related methods on NaiveDateTime Deprecate all timestamp-related methods on NaiveDateTime Feb 28, 2024
@djc
Copy link
Member

djc commented Feb 28, 2024

This makes sense to me.

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

No branches or pull requests

2 participants