Skip to content

Commit

Permalink
Add an even longer duration to the test
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
EliahKagan committed Nov 22, 2024
1 parent 04c82ca commit f7a9887
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gix-date/tests/time/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ mod relative {
("20160 minutes ago", 20_160.minutes()), // 2 weeks
("20 weeks ago", 20.weeks()),
("201600 minutes ago", 201_600.minutes()), // 20 weeks
("40 weeks ago", 40.weeks()),
("403200 minutes ago", 403_200.minutes()), // 40 weeks
];

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

0 comments on commit f7a9887

Please sign in to comment.