pub fn parse_interval(value: Option<&str>) -> Option<u64>Expand description
Parse a CT_UPDATE_CHECK value into a poll interval in seconds, or None
to disable the check entirely.
Accepts the friendly words daily (the default), weekly, hourly,
always (every run — for testing), and the off-switches never / off /
no / false / 0; a bare positive integer is taken as seconds. Anything
unrecognised falls back to the daily default rather than disabling.
use coding_tools::update::parse_interval;
assert_eq!(parse_interval(None), Some(86_400));
assert_eq!(parse_interval(Some("daily")), Some(86_400));
assert_eq!(parse_interval(Some("weekly")), Some(604_800));
assert_eq!(parse_interval(Some("never")), None);
assert_eq!(parse_interval(Some("0")), None);
assert_eq!(parse_interval(Some("3600")), Some(3_600));
assert_eq!(parse_interval(Some("always")), Some(0));
assert_eq!(parse_interval(Some("garbage")), Some(86_400));