Struct jomini::common::RawDate[][src]

pub struct RawDate { /* fields omitted */ }
Expand description

Common implementation between the different date and time formats.

Space optimized to only need 4 bytes

It may or may not have an hour component.

Paradox games do not follow any traditional calendar and instead view the world on simpler terms: that every year should be treated as a non-leap year.

Years can be negative but can’t be zero.

An hour component is considered present if it is non-zero. This means that games with hours run on a non-traditional clock from 1-24 instead of the traditional 24 hour clock (0-23).

A raw date has very minimal validation and can support any calendar system as it holds abitrary values for year, month, day, and hours

It is typically recommended to use one of the specialized types: Date, DateHour, or UniformDate as date formats aren’t variable within a game and have less pitfalls.

Implementations

Create a raw date from individual components.

Will return none for an invalid date

Create a raw date from individual components.

Will panic on invalid dates

Return the hour component. Range [1, 24]. If zero, then there is no hour

Return if this date has an hour component

Parses date components from the following formatted text:

  • Y.M.D
  • Y.M.D.H
  • YYYY.MM.DD.HH
  • or any variation of the above

A zero component for the hour is disallowed, so the hour must be omitted when parsing to only a date without a time component.

Unlike Date::parse, this will not parse the textual form of the date’s binary representation.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Return year of date

Return month of date

Return day of date

Formats the date in the game format

Formats the date in an iso8601 format

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.