module documentation

Parsing of Git's "approxidate" time specifications.

Git uses a flexible date parser called "approxidate" that accepts various formats for specifying dates and times, including: - Relative times: "yesterday", "2 days ago", "2.weeks.ago" - Absolute dates: "2005-04-07", "2005-04-07 22:13:13" - Unix timestamps: "1234567890" - Special keywords: "now", "today", "yesterday"

Function parse_approxidate Parse a Git approxidate specification and return a Unix timestamp.
Function parse_relative_time Parse a relative time string like '2 weeks ago' into seconds.
def parse_approxidate(time_spec: str | bytes) -> int:

Parse a Git approxidate specification and return a Unix timestamp.

Parameters
time_spec:str | bytesTime specification string. Can be: - A Unix timestamp (integer as string) - A relative time like "2 weeks ago" or "2.weeks.ago" - Special keywords: "now", "today", "yesterday" - Absolute date: "2005-04-07" or "2005-04-07 22:13:13"
Returns
intUnix timestamp (seconds since epoch)
Raises
ValueErrorIf the time specification cannot be parsed
def parse_relative_time(time_str: str) -> int:

Parse a relative time string like '2 weeks ago' into seconds.

Parameters
time_str:strString like '2 weeks ago', '2.weeks.ago', or 'now'
Returns
intNumber of seconds (relative to current time)
Raises
ValueErrorIf the time string cannot be parsed