Struct dtparse::ParserInfo

source ·
pub struct ParserInfo {
    pub jump: HashMap<String, usize>,
    pub weekday: HashMap<String, usize>,
    pub months: HashMap<String, usize>,
    pub hms: HashMap<String, usize>,
    pub ampm: HashMap<String, usize>,
    pub utczone: HashMap<String, usize>,
    pub pertain: HashMap<String, usize>,
    pub tzoffset: HashMap<String, usize>,
    pub dayfirst: bool,
    pub yearfirst: bool,
    pub year: i32,
    pub century: i32,
}
Expand description

Container for specific tokens to be recognized during parsing.

  • jump: Values that indicate the end of a token for parsing and can be ignored
  • weekday: Names of the days of the week
  • months: Names of the months
  • hms: Names for the units of time - hours, minutes, seconds in English
  • ampm: AM and PM tokens
  • utczone: Tokens indicating a UTC-timezone string
  • pertain: Tokens indicating a “belongs to” relationship; in English this is just “of”
  • tzoffset:
  • dayfirst: Upon encountering an ambiguous date, treat the first value as the day
  • yearfirst: Upon encountering an ambiguous date, treat the first value as the year
  • year: The current year
  • century: The first year in the current century

Please note that if both dayfirst and yearfirst are true, years take precedence and will be parsed as “YDM”

Fields§

§jump: HashMap<String, usize>

Tokens that can be safely ignored

§weekday: HashMap<String, usize>

Names of all seven weekdays

§months: HashMap<String, usize>

Names of all twelve months

§hms: HashMap<String, usize>

Tokens to indicate a value is in units of hours, minutes, or seconds

§ampm: HashMap<String, usize>

Tokens to indicate a value refers to AM or PM time

§utczone: HashMap<String, usize>

Tokens to indicate our timestamp is in the UTC timezone

§pertain: HashMap<String, usize>

Tokens to indicate values “belonging” to other tokens (e.g. 3rd of March)

§tzoffset: HashMap<String, usize>

Map of timezone names to their offset in seconds

§dayfirst: bool

For ambiguous year/month/day values, and dayfirst was not specified as an argument to Parser, treat the first observed value as the day.

§yearfirst: bool

For ambiguous year/month/day values, and dayfirst was not specified as an argument to Parser, treat the first observed value as the day. Takes priority over dayfirst

§year: i32

The current year we are parsing values for

§century: i32

The current year we are parsing values for modulo 100

Trait Implementations§

source§

impl Debug for ParserInfo

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ParserInfo

source§

fn default() -> Self

Create a basic ParserInfo object suitable for parsing dates in English

source§

impl PartialEq<ParserInfo> for ParserInfo

source§

fn eq(&self, other: &ParserInfo) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for ParserInfo

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.