date: allow negative date offsets#7548
Merged
sylvestre merged 1 commit intouutils:mainfrom Mar 26, 2025
Merged
Conversation
sylvestre
reviewed
Mar 23, 2025
tests/by-util/test_date.rs
Outdated
|
|
||
| #[test] | ||
| fn test_negative_offset() { | ||
| let data_formats = vec!["-1 day", "-2 weeks"]; |
Contributor
There was a problem hiding this comment.
could you please add a check that -1 day is in the past and not in the future ? thanks
Contributor
Author
There was a problem hiding this comment.
Good idea, thanks. I've improved the test to check that the result is +-10 minutes from what we expect. That should give better confidence, but not cause the test to fail intermittently.
Weirdly, I struggled to parse the date when it wasn't rfc-3339, so I ended up adding the --rfc-3339=seconds flag. I can continue to try and get it working if you'd prefer.
|
GNU testsuite comparison: |
Issue uutils#7515 Clap needs to be specifically configured to allow values with a leading hyphen.
68db5fe to
b02e3d5
Compare
Contributor
|
thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Clap needs to be specifically configured to allow values with a leading hyphen
date -d '-2 weeks'is a valid offset.target/debug/coreutils date -d '-2 weeks' Sun Mar 9 22:18:35 GMT 2025date -d '-2 weeks' Sun 9 Mar 22:18:57 GMT 2025closes #7515