-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix military date parsing not adjusting date #9785
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
base: main
Are you sure you want to change the base?
Conversation
CodSpeed Performance ReportMerging #9785 will not alter performanceComparing Summary
Footnotes
|
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
|
GNU testsuite comparison: |
|
also fixes #9798 |
| let date_part = match day_delta { | ||
| DayDelta::Same => { | ||
| strtime::format("%F", &now).unwrap_or_else(|_| String::from("1970-01-01")) | ||
| } | ||
| DayDelta::Next => now | ||
| .tomorrow() | ||
| .and_then(|d| strtime::format("%F", &d)) | ||
| .unwrap_or_else(|_| String::from("1970-01-01")), | ||
| DayDelta::Previous => now | ||
| .yesterday() | ||
| .and_then(|d| strtime::format("%F", &d)) | ||
| .unwrap_or_else(|_| String::from("1970-01-01")), | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can probably simplified with something like:
| let date_part = match day_delta { | |
| DayDelta::Same => { | |
| strtime::format("%F", &now).unwrap_or_else(|_| String::from("1970-01-01")) | |
| } | |
| DayDelta::Next => now | |
| .tomorrow() | |
| .and_then(|d| strtime::format("%F", &d)) | |
| .unwrap_or_else(|_| String::from("1970-01-01")), | |
| DayDelta::Previous => now | |
| .yesterday() | |
| .and_then(|d| strtime::format("%F", &d)) | |
| .unwrap_or_else(|_| String::from("1970-01-01")), | |
| }; | |
| let format_date = |date: Option<Zoned>| -> String { | |
| date.and_then(|d| strtime::format("%F", &d)) | |
| .unwrap_or_else(|_| String::from("1970-01-01")) | |
| }; | |
| let date_part = match day_delta { | |
| DayDelta::Same => format_date(Some(now)), | |
| DayDelta::Next => format_date(now.tomorrow()), | |
| DayDelta::Previous => format_date(now.yesterday()), | |
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tomorrow()/yesterday() return Result but i did implement this closure approach in the newest commit
fixes #9775.
I fixed the bug described in this issue and also added regression tests.
I am pretty sure that the unwrap i added is not okay but i am not sure what fallback date to use if the edgecases of the time is reached and would love for someone to give me some input.