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

date: --date=month and --date=year return wrong date and time #4811

Open
cakebaker opened this issue May 1, 2023 · 3 comments · May be fixed by uutils/parse_datetime#28
Open

date: --date=month and --date=year return wrong date and time #4811

cakebaker opened this issue May 1, 2023 · 3 comments · May be fixed by uutils/parse_datetime#28
Labels

Comments

@cakebaker
Copy link
Contributor

With GNU date:

$ date
Mon May  1 10:36:23 AM CEST 2023
$ date --date=month
Thu Jun  1 10:36:49 AM CEST 2023
$ date --date=year
Wed May  1 10:36:56 AM CEST 2024

With uutils date:

$ cargo run date
Mon May  1 10:37:59 2023
$ cargo run date --date=month
Wed May 31 08:38:06 2023
$ cargo run date --date=year
Tue Apr 30 08:38:12 2024

The time is also incorrect when using --date=week, --date=day, --date=hour, etc.

@sylvestre
Copy link
Contributor

Maybe because we hardcode
month = 30 days
https://github.com/uutils/humantime_to_duration/blob/main/src/lib.rs#LL119C1-L119C1
?

@cakebaker
Copy link
Contributor Author

Yes, plus the year is also hardcoded as 365 days and next year is a leap year.

@wanderinglethe
Copy link
Contributor

wanderinglethe commented Jun 6, 2023

I guess, this is already a problem for minutes (leap seconds)?
Could we use something like chronoutil::RelativeDuration? Not directly, because it only supports months and not weeks, days, minutes, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants