jiff::fmt::strtime::parse

Struct Parser

Source
pub(super) struct Parser<'f, 'i, 't> {
    pub(super) fmt: &'f [u8],
    pub(super) inp: &'i [u8],
    pub(super) tm: &'t mut BrokenDownTime,
}

Fields§

§fmt: &'f [u8]§inp: &'i [u8]§tm: &'t mut BrokenDownTime

Implementations§

Source§

impl<'f, 'i, 't> Parser<'f, 'i, 't>

Source

pub(super) fn parse(&mut self) -> Result<(), Error>

Source

fn f(&self) -> u8

Returns the byte at the current position of the format string.

§Panics

This panics when the entire format string has been consumed.

Source

fn i(&self) -> u8

Returns the byte at the current position of the input string.

§Panics

This panics when the entire input string has been consumed.

Source

fn bump_fmt(&mut self) -> bool

Bumps the position of the format string.

This returns true in precisely the cases where self.f() will not panic. i.e., When the end of the format string hasn’t been reached yet.

Source

fn bump_input(&mut self) -> bool

Bumps the position of the input string.

This returns true in precisely the cases where self.i() will not panic. i.e., When the end of the input string hasn’t been reached yet.

Source

fn parse_extension(&mut self) -> Result<Extension, Error>

Parses optional extensions before a specifier directive. That is, right after the %. If any extensions are parsed, the parser is bumped to the next byte. (If no next byte exists, then an error is returned.)

Source

fn parse_literal(&mut self) -> Result<(), Error>

Parses a literal from the input that matches the current byte in the format string.

This may consume multiple bytes from the input, for example, a single whitespace byte in the format string can match zero or more whitespace in the input.

Source

fn parse_whitespace(&mut self) -> Result<(), Error>

Parses an arbitrary (zero or more) amount ASCII whitespace.

This is for %n and %t.

Source

fn parse_percent(&mut self) -> Result<(), Error>

Parses a literal ‘%’ from the input.

Source

fn parse_american_date(&mut self) -> Result<(), Error>

Parses %D, which is equivalent to %m/%d/%y.

Source

fn parse_ampm(&mut self) -> Result<(), Error>

Parse %p, which indicates whether the time is AM or PM.

This is generally only useful with %I. If, say, %H is used, then the AM/PM moniker will be validated, but it doesn’t actually influence the clock time.

Source

fn parse_clock_secs(&mut self) -> Result<(), Error>

Parses %T, which is equivalent to %H:%M:%S.

Source

fn parse_clock_nosecs(&mut self) -> Result<(), Error>

Parses %R, which is equivalent to %H:%M.

Source

fn parse_day(&mut self, ext: Extension) -> Result<(), Error>

Parses %d and %e, which is equivalent to the day of the month.

We merely require that it is in the range 1-31 here.

Source

fn parse_day_of_year(&mut self, ext: Extension) -> Result<(), Error>

Parses %j, which is equivalent to the day of the year.

We merely require that it is in the range 1-366 here.

Source

fn parse_hour24(&mut self, ext: Extension) -> Result<(), Error>

Parses %H, which is equivalent to the hour.

Source

fn parse_hour12(&mut self, ext: Extension) -> Result<(), Error>

Parses %I, which is equivalent to the hour on a 12-hour clock.

Source

fn parse_iso_date(&mut self) -> Result<(), Error>

Parses %F, which is equivalent to %Y-%m-%d.

Source

fn parse_minute(&mut self, ext: Extension) -> Result<(), Error>

Parses %M, which is equivalent to the minute.

Source

fn parse_iana_nocolon(&mut self) -> Result<(), Error>

Parse %Q, which is the IANA time zone identifier or an offset without colons.

Source

fn parse_iana_colon(&mut self) -> Result<(), Error>

Parse %:Q, which is the IANA time zone identifier or an offset with colons.

Source

fn parse_offset_nocolon(&mut self) -> Result<(), Error>

Parse %z, which is a time zone offset without colons.

Source

fn parse_offset_colon(&mut self) -> Result<(), Error>

Parse %:z, which is a time zone offset with colons.

Source

fn parse_second(&mut self, ext: Extension) -> Result<(), Error>

Parses %S, which is equivalent to the second.

Source

fn parse_timestamp(&mut self, ext: Extension) -> Result<(), Error>

Parses %s, which is equivalent to a Unix timestamp.

Source

fn parse_fractional(&mut self, _ext: Extension) -> Result<(), Error>

Parses %f, which is equivalent to a fractional second up to nanosecond precision. This must always parse at least one decimal digit and does not parse any leading dot.

At present, we don’t use any flags/width/precision settings to influence parsing. That is, %3f will parse the fractional component in 0.123456789.

Source

fn parse_dot_fractional(&mut self, ext: Extension) -> Result<(), Error>

Parses %f, which is equivalent to a dot followed by a fractional second up to nanosecond precision. Note that if there is no leading dot, then this successfully parses the empty string.

Source

fn parse_month(&mut self, ext: Extension) -> Result<(), Error>

Parses %m, which is equivalent to the month.

Source

fn parse_month_name_abbrev(&mut self) -> Result<(), Error>

Parse %b or %h, which is an abbreviated month name.

Source

fn parse_month_name_full(&mut self) -> Result<(), Error>

Parse %B, which is a full month name.

Source

fn parse_weekday_abbrev(&mut self) -> Result<(), Error>

Parse %a, which is an abbreviated weekday.

Source

fn parse_weekday_full(&mut self) -> Result<(), Error>

Parse %A, which is a full weekday name.

Source

fn parse_weekday_mon(&mut self, ext: Extension) -> Result<(), Error>

Parse %u, which is a weekday number with Monday being 1 and Sunday being 7.

Source

fn parse_weekday_sun(&mut self, ext: Extension) -> Result<(), Error>

Parse %w, which is a weekday number with Sunday being 0.

Source

fn parse_week_sun(&mut self, ext: Extension) -> Result<(), Error>

Parse %U, which is a week number with Sunday being the first day in the first week numbered 01.

Source

fn parse_week_iso(&mut self, ext: Extension) -> Result<(), Error>

Parse %V, which is an ISO 8601 week number.

Source

fn parse_week_mon(&mut self, ext: Extension) -> Result<(), Error>

Parse %W, which is a week number with Monday being the first day in the first week numbered 01.

Source

fn parse_year(&mut self, ext: Extension) -> Result<(), Error>

Parses %Y, which we permit to be any year, including a negative year.

Source

fn parse_year2(&mut self, ext: Extension) -> Result<(), Error>

Parses %y, which is equivalent to a 2-digit year.

The numbers 69-99 refer to 1969-1999, while 00-68 refer to 2000-2068.

Source

fn parse_century(&mut self, ext: Extension) -> Result<(), Error>

Parses %C, which we permit to just be a century, including a negative century.

Source

fn parse_iso_week_year(&mut self, ext: Extension) -> Result<(), Error>

Parses %G, which we permit to be any year, including a negative year.

Source

fn parse_iso_week_year2(&mut self, ext: Extension) -> Result<(), Error>

Parses %g, which is equivalent to a 2-digit ISO 8601 week-based year.

The numbers 69-99 refer to 1969-1999, while 00-68 refer to 2000-2068.

Auto Trait Implementations§

§

impl<'f, 'i, 't> Freeze for Parser<'f, 'i, 't>

§

impl<'f, 'i, 't> RefUnwindSafe for Parser<'f, 'i, 't>

§

impl<'f, 'i, 't> Send for Parser<'f, 'i, 't>

§

impl<'f, 'i, 't> Sync for Parser<'f, 'i, 't>

§

impl<'f, 'i, 't> Unpin for Parser<'f, 'i, 't>

§

impl<'f, 'i, 't> !UnwindSafe for Parser<'f, 'i, 't>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.