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

OffsetDateTime -> PrimitiveDateTime #553

Closed
lpotthast opened this issue Feb 18, 2023 · 1 comment
Closed

OffsetDateTime -> PrimitiveDateTime #553

lpotthast opened this issue Feb 18, 2023 · 1 comment
Labels
C-duplicate Category: exact duplicate

Comments

@lpotthast
Copy link

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.

@jhpratt
Copy link
Member

jhpratt commented Feb 18, 2023

Duplicate of #369, #390, #395, #454, and #458.

@jhpratt jhpratt closed this as not planned Won't fix, can't repro, duplicate, stale Feb 18, 2023
@jhpratt jhpratt added the C-duplicate Category: exact duplicate label Feb 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-duplicate Category: exact duplicate
Projects
None yet
Development

No branches or pull requests

2 participants