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.
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 UTCdt.timestamp()
would becomedt.and_utc().timestamp()
.NaiveDate::from_timestamp(ts, 0)
would becomeUtc.timestamp(ts, 0).naive_utc()
.Deprecating these methods can help users notice invalid assumptions, and removes 13 methods from our API surface.