Skip to main content

parse_window

Function parse_window 

Source
pub fn parse_window(spec: &str) -> Result<i64, Error>
Available on crate feature vcs-git only.
Expand description

Parse a human time-window string into seconds.

Accepts a suffix form — <number><unit> with unit d (days), w (weeks), mo (months), or y (years) — or an ISO 8601 duration (P12M, P90D, P2Y, P8W). Months and years use the average Gregorian length, so 12mo, 1y, and P1Y all resolve to 365 days.

§Errors

Returns Error::InvalidWindow when the input is empty, carries an unrecognised unit, or has a non-numeric magnitude.