You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can use assume_utc and others to convert a PrimitiveDateTime to an OffsetDateTime.
But there does not seem to be an easy way of converting back to a PrimitiveDateTime, that means: simply dropping the offset information.
Use case: Use PrimitiveDateTime for something like a database field, at which no offset information is required (UTC always implied). We still want to use "now" functions. As there is only OffsetDateTime::now_utc() and no PrimitiveDateTime::now_***(), a conversion only seems possible with
{
let now = time::OffsetDateTime::now_utc();
time::PrimitiveDateTime::new(now.date(), now.time())
}
I think there should either be a From/Into implementation or an appropriately named function for some or both types, which lets you do this using a single function call.
The text was updated successfully, but these errors were encountered:
We can use
assume_utc
and others to convert aPrimitiveDateTime
to anOffsetDateTime
.But there does not seem to be an easy way of converting back to a
PrimitiveDateTime
, that means: simply dropping the offset information.Use case: Use
PrimitiveDateTime
for something like a database field, at which no offset information is required (UTC always implied). We still want to use "now" functions. As there is onlyOffsetDateTime::now_utc()
and noPrimitiveDateTime::now_***()
, a conversion only seems possible withI think there should either be a
From
/Into
implementation or an appropriately named function for some or both types, which lets you do this using a single function call.The text was updated successfully, but these errors were encountered: