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>
impl<'f, 'i, 't> Parser<'f, 'i, 't>
pub(super) fn parse(&mut self) -> Result<(), Error>
Sourcefn f(&self) -> u8
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.
Sourcefn i(&self) -> u8
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.
Sourcefn bump_fmt(&mut self) -> bool
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.
Sourcefn bump_input(&mut self) -> bool
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.
Sourcefn parse_extension(&mut self) -> Result<Extension, Error>
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.)
Sourcefn parse_literal(&mut self) -> Result<(), Error>
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.
Sourcefn parse_whitespace(&mut self) -> Result<(), Error>
fn parse_whitespace(&mut self) -> Result<(), Error>
Parses an arbitrary (zero or more) amount ASCII whitespace.
This is for %n
and %t
.
Sourcefn parse_percent(&mut self) -> Result<(), Error>
fn parse_percent(&mut self) -> Result<(), Error>
Parses a literal ‘%’ from the input.
Sourcefn parse_american_date(&mut self) -> Result<(), Error>
fn parse_american_date(&mut self) -> Result<(), Error>
Parses %D
, which is equivalent to %m/%d/%y
.
Sourcefn parse_ampm(&mut self) -> Result<(), Error>
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.
Sourcefn parse_clock_secs(&mut self) -> Result<(), Error>
fn parse_clock_secs(&mut self) -> Result<(), Error>
Parses %T
, which is equivalent to %H:%M:%S
.
Sourcefn parse_clock_nosecs(&mut self) -> Result<(), Error>
fn parse_clock_nosecs(&mut self) -> Result<(), Error>
Parses %R
, which is equivalent to %H:%M
.
Sourcefn parse_day(&mut self, ext: Extension) -> Result<(), Error>
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.
Sourcefn parse_day_of_year(&mut self, ext: Extension) -> Result<(), Error>
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.
Sourcefn parse_hour24(&mut self, ext: Extension) -> Result<(), Error>
fn parse_hour24(&mut self, ext: Extension) -> Result<(), Error>
Parses %H
, which is equivalent to the hour.
Sourcefn parse_hour12(&mut self, ext: Extension) -> Result<(), Error>
fn parse_hour12(&mut self, ext: Extension) -> Result<(), Error>
Parses %I
, which is equivalent to the hour on a 12-hour clock.
Sourcefn parse_iso_date(&mut self) -> Result<(), Error>
fn parse_iso_date(&mut self) -> Result<(), Error>
Parses %F
, which is equivalent to %Y-%m-%d
.
Sourcefn parse_minute(&mut self, ext: Extension) -> Result<(), Error>
fn parse_minute(&mut self, ext: Extension) -> Result<(), Error>
Parses %M
, which is equivalent to the minute.
Sourcefn parse_iana_nocolon(&mut self) -> Result<(), Error>
fn parse_iana_nocolon(&mut self) -> Result<(), Error>
Parse %Q
, which is the IANA time zone identifier or an offset without
colons.
Sourcefn parse_iana_colon(&mut self) -> Result<(), Error>
fn parse_iana_colon(&mut self) -> Result<(), Error>
Parse %:Q
, which is the IANA time zone identifier or an offset with
colons.
Sourcefn parse_offset_nocolon(&mut self) -> Result<(), Error>
fn parse_offset_nocolon(&mut self) -> Result<(), Error>
Parse %z
, which is a time zone offset without colons.
Sourcefn parse_offset_colon(&mut self) -> Result<(), Error>
fn parse_offset_colon(&mut self) -> Result<(), Error>
Parse %:z
, which is a time zone offset with colons.
Sourcefn parse_second(&mut self, ext: Extension) -> Result<(), Error>
fn parse_second(&mut self, ext: Extension) -> Result<(), Error>
Parses %S
, which is equivalent to the second.
Sourcefn parse_timestamp(&mut self, ext: Extension) -> Result<(), Error>
fn parse_timestamp(&mut self, ext: Extension) -> Result<(), Error>
Parses %s
, which is equivalent to a Unix timestamp.
Sourcefn parse_fractional(&mut self, _ext: Extension) -> Result<(), Error>
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
.
Sourcefn parse_dot_fractional(&mut self, ext: Extension) -> Result<(), Error>
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.
Sourcefn parse_month(&mut self, ext: Extension) -> Result<(), Error>
fn parse_month(&mut self, ext: Extension) -> Result<(), Error>
Parses %m
, which is equivalent to the month.
Sourcefn parse_month_name_abbrev(&mut self) -> Result<(), Error>
fn parse_month_name_abbrev(&mut self) -> Result<(), Error>
Parse %b
or %h
, which is an abbreviated month name.
Sourcefn parse_month_name_full(&mut self) -> Result<(), Error>
fn parse_month_name_full(&mut self) -> Result<(), Error>
Parse %B
, which is a full month name.
Sourcefn parse_weekday_abbrev(&mut self) -> Result<(), Error>
fn parse_weekday_abbrev(&mut self) -> Result<(), Error>
Parse %a
, which is an abbreviated weekday.
Sourcefn parse_weekday_full(&mut self) -> Result<(), Error>
fn parse_weekday_full(&mut self) -> Result<(), Error>
Parse %A
, which is a full weekday name.
Sourcefn parse_weekday_mon(&mut self, ext: Extension) -> Result<(), Error>
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
.
Sourcefn parse_weekday_sun(&mut self, ext: Extension) -> Result<(), Error>
fn parse_weekday_sun(&mut self, ext: Extension) -> Result<(), Error>
Parse %w
, which is a weekday number with Sunday being 0
.
Sourcefn parse_week_sun(&mut self, ext: Extension) -> Result<(), Error>
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
.
Sourcefn parse_week_iso(&mut self, ext: Extension) -> Result<(), Error>
fn parse_week_iso(&mut self, ext: Extension) -> Result<(), Error>
Parse %V
, which is an ISO 8601 week number.
Sourcefn parse_week_mon(&mut self, ext: Extension) -> Result<(), Error>
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
.
Sourcefn parse_year(&mut self, ext: Extension) -> Result<(), Error>
fn parse_year(&mut self, ext: Extension) -> Result<(), Error>
Parses %Y
, which we permit to be any year, including a negative year.
Sourcefn parse_year2(&mut self, ext: Extension) -> Result<(), Error>
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.
Sourcefn parse_century(&mut self, ext: Extension) -> Result<(), Error>
fn parse_century(&mut self, ext: Extension) -> Result<(), Error>
Parses %C
, which we permit to just be a century, including a negative
century.