From 5cf8a6fbdd59206f57a68627d7323e4944661916 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 13 Feb 2026 20:50:50 +0100 Subject: [PATCH] date: add more tests leap year overflow --- tests/date.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/date.rs b/tests/date.rs index 0f12cc0..d440585 100644 --- a/tests/date.rs +++ b/tests/date.rs @@ -112,3 +112,18 @@ fn test_tz_prefix_with_base_date(#[case] input: &str, #[case] expected: &str) { .unwrap(); check_relative(base, input, expected); } + +// Test leap year overflow: Feb 29 + years → non-leap year should overflow to March 1 +// This matches GNU date behavior +#[rstest] +#[case::feb29_1996_plus_1year("1996-02-29 00:00:00", "1 year", "1997-03-01 00:00:00+00:00")] +#[case::feb29_2020_plus_1year("2020-02-29 00:00:00", "1 year", "2021-03-01 00:00:00+00:00")] +#[case::feb29_2000_plus_1year("2000-02-29 00:00:00", "1 year", "2001-03-01 00:00:00+00:00")] +fn test_leap_year_overflow(#[case] base: &str, #[case] input: &str, #[case] expected: &str) { + let now = base + .parse::() + .unwrap() + .to_zoned(TimeZone::UTC) + .unwrap(); + check_relative(now, input, expected); +}