Skip to content

Commit c4e3ca6

Browse files
authored
date: bump parse_datetime & add test for leap-1 GNU test (#10933)
Rely on parse_datetime update Test that adding years to Feb 29 overflows to March 1 when target year is not a leap year (matching GNU behavior).
1 parent 0c41299 commit c4e3ca6

File tree

4 files changed

+35
-12
lines changed

4 files changed

+35
-12
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ num-bigint = "0.4.4"
360360
num-prime = "0.4.4"
361361
num-traits = "0.2.19"
362362
onig = { version = "~6.5.1", default-features = false }
363-
parse_datetime = "0.13.0"
363+
parse_datetime = "0.14.0"
364364
phf = "0.13.1"
365365
phf_codegen = "0.13.1"
366366
platform-info = "2.0.3"

fuzz/Cargo.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/by-util/test_date.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,3 +2113,26 @@ fn test_date_write_error_dev_full() {
21132113
.fails()
21142114
.stderr_contains("write error");
21152115
}
2116+
2117+
// Tests for GNU test leap-1: leap year overflow in date arithmetic
2118+
#[test]
2119+
fn test_date_leap1_leap_year_overflow() {
2120+
// GNU test leap-1: Adding years to Feb 29 should overflow to March 1
2121+
// if target year is not a leap year
2122+
new_ucmd!()
2123+
.args(&["--date", "02/29/1996 1 year", "+%Y-%m-%d"])
2124+
.succeeds()
2125+
.stdout_is("1997-03-01\n");
2126+
2127+
// Additional cases: 2 years
2128+
new_ucmd!()
2129+
.args(&["--date", "1996-02-29 + 2 years", "+%Y-%m-%d"])
2130+
.succeeds()
2131+
.stdout_is("1998-03-01\n");
2132+
2133+
// Leap year to leap year should not overflow
2134+
new_ucmd!()
2135+
.args(&["--date", "1996-02-29 + 4 years", "+%Y-%m-%d"])
2136+
.succeeds()
2137+
.stdout_is("2000-02-29\n");
2138+
}

0 commit comments

Comments
 (0)