pub fn parse_fuzzy(source: &str) -> Result<(i64, i64, Duration), ParseError>Expand description
Parse the source string extracting year and month time units from the Duration
Unlike RelativeTimeParser::parse and RelativeTimeParser::parse_with_date this method
won’t interpret the parsed year and month time units but simply returns the values
parsed from the source string.
The returned tuple (years, months, Duration) contains in the first component the
amount parsed years as i64, in the second component the parsed months as i64 and in
the last component the rest of the parsed time units accumulated as Duration.
This method is equivalent to RelativeTimeParser::parse_fuzzy. See also the documentation of
RelativeTimeParser::parse_fuzzy.
§Errors
Returns a ParseError if an error during the parsing process occurred.
§Examples
use fundu_gnu::{parse_fuzzy, Duration};
assert_eq!(
parse_fuzzy("2hours"),
Ok((0, 0, Duration::positive(2 * 60 * 60, 0)))
);
assert_eq!(
parse_fuzzy("2hours +123month -10years"),
Ok((-10, 123, Duration::positive(2 * 60 * 60, 0)))
);