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
Is there a simpler way to get the current date at a specific time? #1447
Comments
I am afraid that is pretty much it. let today = Local::now().date_naive();
let midnight = NaiveTime::MIN;
let today_at_midnight = Local.from_local_datetime(today.and_time(midnight)).unwrap(); // or handle the result |
Thank you!! The tip with NaiveTime::MIN is neat, it can remove one of the unwrap(). In the end I made this helper because I use that pattern a lot, especially for 00:00.
If you are interested to get this in the API of chrono please let me know and I will make a PR. (Adapted to use NaiveTime probably) |
I am hoping to have I'll leave this issue open though. Maybe |
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()
:The text was updated successfully, but these errors were encountered: