jiff::fmt::util

Function parse_temporal_fraction

Source
pub(crate) fn parse_temporal_fraction<'i>(
    input: &'i [u8],
) -> Result<Parsed<'i, Option<ri32<0, { _ }>>>, Error>
Expand description

Parses an optional fractional number from the start of input.

If input does not begin with a . (or a ,), then this returns None and no input is consumed. Otherwise, up to 9 ASCII digits are parsed after the decimal separator.

While this is most typically used to parse the fractional component of second units, it is also used to parse the fractional component of hours or minutes in ISO 8601 duration parsing, and milliseconds and microseconds in the “friendly” duration format. The return type in that case is obviously a misnomer, but the range of possible values is still correct. (That is, the fractional component of an hour is still limited to 9 decimal places per the Temporal spec.)