zabgrab.adapters.dates¶
Parsing of user-supplied times, such as 2026-10-14 09:00 or 24 hours ago.
Functions
|
Parse a time typed by the user, returning an aware UTC datetime. |
|
Get the time zone for a |
- zabgrab.adapters.dates.parse_time(text, *, now, tz)[source]¶
Parse a time typed by the user, returning an aware UTC datetime.
ISO 8601 (
2026-10-14,2026-10-14 09:00,2026-10-14T09:00:00Z) is parsed exactly. Anything else goes to dateparser, which understands relative times and natural language, with day-first numeric dates (14/10/2026). Times without an explicit offset are intz(Nonefor local time), and relative times are relative tonow.- Parameters:
text (str) – The time as typed.
now (datetime) – The current time, for relative times.
tz (tzinfo or None) – The time zone for times without an offset (
Nonefor local time).
- Returns:
datetime – The time, as an aware UTC datetime.
- Raises:
ValueError – With a message suitable for showing to the user.
- Return type: