Open xeruf opened 4 weeks ago
@conradludgate might also be interesting for your fork https://github.com/conradludgate/interim, which will be my preferred parser with fallback to this one, because each handles some relative times better:
parse_datetime
can handle plain expressions like week
, fortnight
, day
and stacked relative times such as -1h1m
, and handle a +
prefix as well as last
and next
interim
and chrono-english
understand - they understand shorthands for day(d)
and year(y)
unlike parse_datetime, as well as calculating month and year offsets more accuratelyin X
expressions (in 1 hour
should be equivalent to +1h
) as well as DATE at TIME
-X
and X ago
for day
, hour
, minute
, second
Irrelevant sidenote: Only chrono-english understands 1se
and 1M
.
with years business gets funny:
For interim, I intended to keep all the quirks of chrono-english for compatibility, but with less panics. I'll admit I haven't given too much thought to the actual cases. I'm open to adding new features if desired
@conradludgate that would be great, if you could add these I could fully rely on interim: https://github.com/conradludgate/interim/issues/7
@xeruf you could please replace your screenshots by text? They are terrible for search, reproducibility and accessibility
Wrote a small helper to compare to chrono-english. Apart from #23 and #83, I found some other small issues:
year ago
produces a one-day offset, presumably because of leap years not being accounted fortoday
, while being consistent in both tools, I would expect to refer to the day start rather than the current time-1h1m
should be 61 minutes ago, the preceding minus shall negate the whole expression. It should understand-1h +1m
for 59 minutes ago.