Skip to main content

positive_seconds

Function positive_seconds 

Source
pub fn positive_seconds(name: &str, value: &OsStr) -> Option<Duration>
Expand description

What: Read a positive whole number of seconds from one environment value. Why: A zero, negative, fractional, empty or non-text value is no setting at all, never “no limit”, so a typo cannot remove a bound.

In TS you’d write (pseudocode):

const seconds = Number(value); return Number.isInteger(seconds) && seconds > 0 ? seconds * 1000 : undefined;