You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This extends `gix_date::parse::relative::span` to recognize times
with "months" and "years", as in "3 months ago" and "2 years ago".
The actual change here is very simple, because it is directly
facilitated by GitoxideLabs#1474.
The units "seconds", "minutes", "hours", "days", and "weeks"
continue to be recognized (as before). Relative times like
"1 year, 2 months ago" remain unrecognized.
For background, see 43b6c06 (GitoxideLabs#498), c5c6bf6,
GitoxideLabs#1474 (comment),
and
GitoxideLabs#1696 (comment).
Note that this change does not fix issue GitoxideLabs#1696, which continues to
apply to the intepretation of "days" and "weeks", and now also
applies in the same way to the interpretation of "months" and
"years". (It continues not to apply to the interpretation of
"seconds", "minutes", and "hours".)
The tests are updated to cover "months" and "years", as well as to
exercise a wider range of relative times, including showing which
units (e.g. "days") are affected by GitoxideLabs#1696. A few sub-cases, of
those adjusted or added here, test strings from a related test in
Git, to allow comparison. But most are not related to cases there.
As before, the tests pass on CI, or when the time zone is otherwise
UTC, or with local time zones that never have DST adjustments.
The sub-cases are reordered to be monotone increasing in the
magnitude of the relative intervals tested (and thus monotone
decreasing in the associated absolute timestamps), and the original
input is kept zipped into the `actual` and `expected` arrays being
compared. This way, if the assertion fails (such as due to GitoxideLabs#1696),
it is clear and readable which sub-cases failed and exactly how, as
well as what all the sub-cases are and what each sub-case tests.
Reordering the sub-cases and preserving the inputs they parse in
this way avoids the disadvantages of GitoxideLabs#1697 while keeping, and
expanding on, its benefits.
Failure, where 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:252:9:
assertion failed: `(left == right)`: relative times differ
Diff < left / right > :
[
(
"5 seconds ago",
2024-11-24T23:51:49Z,
),
(
"5 minutes ago",
2024-11-24T23:46:54Z,
),
(
"5 hours ago",
2024-11-24T18:51:54Z,
),
(
"5 days ago",
2024-11-19T23:51:54Z,
),
(
"3 weeks ago",
2024-11-03T23:51:54Z,
),
(
"21 days ago",
2024-11-03T23:51:54Z,
),
(
"504 hours ago",
2024-11-03T23:51:54Z,
),
(
"30240 minutes ago",
2024-11-03T23:51:54Z,
),
(
"2 months ago",
< 2024-09-24T23:51:54Z,
> 2024-09-24T22:51:54Z,
),
(
"1460 hours ago",
2024-09-25T03:51:54Z,
),
(
"87600 minutes ago",
2024-09-25T03:51:54Z,
),
(
"14 weeks ago",
< 2024-08-18T23:51:54Z,
> 2024-08-18T22:51:54Z,
),
(
"98 days ago",
< 2024-08-18T23:51:54Z,
> 2024-08-18T22:51:54Z,
),
(
"2352 hours ago",
2024-08-18T23:51:54Z,
),
(
"141120 minutes ago",
2024-08-18T23:51:54Z,
),
(
"5 months ago",
< 2024-06-24T23:51:54Z,
> 2024-06-24T22:51:54Z,
),
(
"3650 hours ago",
2024-06-25T21:51:54Z,
),
(
"219000 minutes ago",
2024-06-25T21:51:54Z,
),
(
"26 weeks ago",
< 2024-05-26T23:51:54Z,
> 2024-05-26T22:51:54Z,
),
(
"182 days ago",
< 2024-05-26T23:51:54Z,
> 2024-05-26T22:51:54Z,
),
(
"4368 hours ago",
2024-05-26T23:51:54Z,
),
(
"262080 minutes ago",
2024-05-26T23:51:54Z,
),
(
"8 months ago",
< 2024-03-24T23:51:54Z,
> 2024-03-24T22:51:54Z,
),
(
"5840 hours ago",
2024-03-26T15:51:54Z,
),
(
"350400 minutes ago",
2024-03-26T15:51:54Z,
),
(
"38 weeks ago",
2024-03-03T23:51:54Z,
),
(
"266 days ago",
2024-03-03T23:51:54Z,
),
(
"6384 hours ago",
2024-03-03T23:51:54Z,
),
(
"383040 minutes ago",
2024-03-03T23:51:54Z,
),
(
"11 months ago",
2023-12-24T23:51:54Z,
),
(
"8030 hours ago",
2023-12-26T09:51:54Z,
),
(
"481800 minutes ago",
2023-12-26T09:51:54Z,
),
(
"14 months ago",
< 2023-09-24T23:51:54Z,
> 2023-09-24T22:51:54Z,
),
(
"21 months ago",
2023-02-24T23:51:54Z,
),
(
"2 years ago",
2022-11-24T23:51:54Z,
),
(
"20 years ago",
2004-11-24T23:51:54Z,
),
(
"630720000 seconds ago",
2004-11-29T23:51:54Z,
),
]
0 commit comments