Skip to main content

Module timestamp

Module timestamp 

Source
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 into ParsedTimestamp.
  • repeater — repeater grammar and occurrence math (+1d, ++2w, .+1m, +1wd).
  • weekdays — localized weekday name normalization (RU → EN).

Structs§

ParsedTimestamp
Result of parsing a single org-mode timestamp string.
Repeater
Repeater type and interval
TimestampParts
A timestamp located token by token, for a caller that rewrites its date.

Enums§

DatePreference
Preference for closest date calculation
RepeaterType
Type of repeater (org-mode prefix)
RepeaterUnit
Repeater unit

Functions§

add_months
Add months to a date, truncating the day to fit the destination month. Constant-time (no per-month loops), correct for negative months.
closest_date
Calculate closest occurrence date relative to current for 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), or None when the timestamp carries no repeater. Input is expected already weekday-normalised (as assembled by extract_timestamp_normalized); a timestamp whose date does not parse yields None (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_fields for callers that have already weekday-normalised the input (e.g. parser::finalize_task, where info.timestamp was assembled from extract_timestamp_normalized’s regex captures over a normalize_weekdays output). 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 return None when there is none.