Expand description
Org-mode timestamp parsing and repeater logic.
Submodule layout:
extract— pull timestamp / CREATED strings out of free-form text.parser— parse a single org-style timestamp intoParsedTimestamp.repeater— repeater grammar and occurrence math (+1d,++2w,.+1m,+1wd).weekdays— localized weekday name normalization (RU → EN).
Structs§
- Parsed
Timestamp - Result of parsing a single org-mode timestamp string.
- Repeater
- Repeater type and interval
- Timestamp
Parts - A timestamp located token by token, for a caller that rewrites its date.
Enums§
- Date
Preference - Preference for closest date calculation
- Repeater
Type - Type of repeater (org-mode prefix)
- Repeater
Unit - Repeater unit
Functions§
- add_
months - Add
monthsto a date, truncating the day to fit the destination month. Constant-time (no per-month loops), correct for negativemonths. - closest_
date - Calculate closest occurrence date relative to
currentfor the given repeater. - extract_
created_ normalized - Extract CREATED timestamp from already-weekday-normalized text. Callers in the parser pre-normalize so multiple extractors share one scan; tests pass already-English input.
- extract_
repeater_ normalized - Extract the timestamp’s repeater as its canonical org string
(
++7d,.+1m,+1wd), orNonewhen the timestamp carries no repeater. Input is expected already weekday-normalised (as assembled byextract_timestamp_normalized); a timestamp whose date does not parse yieldsNone(an invalid timestamp is not synced downstream). - extract_
timestamp_ normalized - Extract non-CREATED timestamp from already-weekday-normalized text.
- parse_
org_ timestamp - Parse a single org-mode timestamp like
<2024-12-05 Thu 10:00 +1d>or<2024-12-05>--<2024-12-06>, optionally normalizing localized weekday names. - parse_
repeater - Parse repeater string like
+1d,++2w,.+1m,+1wd - parse_
timestamp_ fields_ normalized - Fast-path companion to
parse_timestamp_fieldsfor callers that have already weekday-normalised the input (e.g.parser::finalize_task, whereinfo.timestampwas assembled fromextract_timestamp_normalized’s regex captures over anormalize_weekdaysoutput). Skipping the second normalisation removes a per-task Aho-Corasick scan on the timestamp substring. - parse_
timestamp_ parts - Locate the first timestamp in
text, or returnNonewhen there is none.