1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

date -d supports - 1 year ago, 2 second, etc

This commit is contained in:
Sylvestre Ledru 2023-04-26 00:11:11 +02:00
parent 6f0e4ece9d
commit 825d240ef0
4 changed files with 47 additions and 3 deletions

View file

@ -334,6 +334,29 @@ fn test_invalid_format_string() {
assert!(result.stderr_str().starts_with("date: invalid format "));
}
#[test]
fn test_date_string_human() {
let date_formats = vec![
"1 year ago",
"1 year",
"2 months ago",
"15 days ago",
"1 week ago",
"5 hours ago",
"30 minutes ago",
"10 seconds",
];
let re = Regex::new(r"^\d{4}-\d{2}-\d{2} \d{2}:\d{2}\n$").unwrap();
for date_format in date_formats {
new_ucmd!()
.arg("-d")
.arg(date_format)
.arg("+%Y-%m-%d %S:%M")
.succeeds()
.stdout_matches(&re);
}
}
#[test]
fn test_invalid_date_string() {
new_ucmd!()