Skip to content

Is there a simpler way to get the current date at a specific time? #1447

@cecton

Description

@cecton

I was wondering if there is a more idiomatic way to retrieve a date like "today at 00:00"?

This is what I have come up with but it's full of unwrap():

Local.from_local_datetime(&Local::now().date_naive().and_hms_opt(0, 0, 0).unwrap()).unwrap()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions