Skip to content

Commit f7a9887

Browse files
committed
Add an even longer duration to the test
This duration, 40 weeks, serves to demonstrate that the actual versus expected value disagreement of 1 hour is due to DST adjustments. Even where DST is observed, adjustments would ordinarily have been done twice in 40 weeks. So this case should not fail, even when the 20 weeks case does. However, the test remains imperfect, even assuming it is run with the time zone set to local time and in a place where DST adustments are made, because there will sometimes never have been exactly one DST adjustment in any of the last 2, 20, or 40 weeks. Better temporal coverage should probably be put in place, but something like the 40 weeks case might still make sense to keep in, so that we are more likely to catch a possible variant of GitoxideLabs#1696 where the time zone rules had at one time had daylight savings but were changed to no longer have it (or vice versa). It's possible that GitoxideLabs#1696 might be fixed by a change to the tested code, or to the test, while still leaving such a variant in place. Failure, when it occurs, now looks like: --- STDERR: gix-date::date time::parse::relative::various --- thread 'time::parse::relative::various' panicked at gix-date\tests\time\parse.rs:211:9: assertion `left == right` failed: relative times differ left: [2024-11-08T21:14:45Z, 2024-11-08T21:14:45Z, 2024-07-05T21:14:45Z, 2024-07-05T21:14:45Z, 2024-02-16T21:14:45Z, 2024-02-16T21:14:45Z] right: [2024-11-08T21:14:45Z, 2024-11-08T21:14:45Z, 2024-07-05T20:14:45Z, 2024-07-05T21:14:45Z, 2024-02-16T21:14:45Z, 2024-02-16T21:14:45Z]
1 parent 04c82ca commit f7a9887

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

gix-date/tests/time/parse.rs

+2
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ mod relative {
185185
("20160 minutes ago", 20_160.minutes()), // 2 weeks
186186
("20 weeks ago", 20.weeks()),
187187
("201600 minutes ago", 201_600.minutes()), // 20 weeks
188+
("40 weeks ago", 40.weeks()),
189+
("403200 minutes ago", 403_200.minutes()), // 40 weeks
188190
];
189191

190192
let times = cases.map(|(input, _)| gix_date::parse(input, Some(now)).unwrap());

0 commit comments

Comments
 (0)