Struct jomini::common::UniformDate [−][src]
pub struct UniformDate { /* fields omitted */ }
Expand description
A date without a time component where each month has 30 days
Useful for Stellaris
See RawDate for additional date / time commentary
Implementations
Create a new date from year, month, and day parts
Will return None
if the date does not exist
use jomini::common::{PdsDate, UniformDate};
assert_eq!(UniformDate::from_ymd_opt(1444, 11, 11), Some(UniformDate::from_ymd(1444, 11, 11)));
assert_eq!(UniformDate::from_ymd_opt(800, 5, 3), Some(UniformDate::from_ymd(800, 5, 3)));
assert!(UniformDate::from_ymd_opt(800, 0, 3).is_none());
assert!(UniformDate::from_ymd_opt(800, 1, 0).is_none());
assert!(UniformDate::from_ymd_opt(800, 13, 1).is_none());
assert!(UniformDate::from_ymd_opt(800, 12, 32).is_none());
assert!(UniformDate::from_ymd_opt(2020, 2, 29).is_some());
Create a new date from year, month, and day parts
Will panic if the date does not exist.
Parse a DateHour from text. Follows the same logic as RawDate::parse except that a 12 month calendar of 30 days is enforced.
use jomini::common::UniformDate;
assert_eq!(UniformDate::parse("2200.02.30"), Ok(UniformDate::from_ymd(2200, 2, 30)));
Trait Implementations
fn deserialize<D>(deserializer: D) -> Result<UniformDate, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<UniformDate, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. 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
Year of the date
use jomini::common::{UniformDate, PdsDate};
let date = UniformDate::from_ymd(1444, 2, 3);
assert_eq!(date.year(), 1444);
Month of the date
use jomini::common::{UniformDate, PdsDate};
let date = UniformDate::from_ymd(1444, 2, 3);
assert_eq!(date.month(), 2);
Day of the date
use jomini::common::{UniformDate, PdsDate};
let date = UniformDate::from_ymd(1444, 2, 3);
assert_eq!(date.day(), 3);
Formats a date in the ISO 8601 format: YYYY-MM-DD
use jomini::common::{UniformDate, PdsDate};
let date = UniformDate::from_ymd(1400, 1, 2);
assert_eq!(date.iso_8601().to_string(), String::from("1400-01-02"));
Formats a date in the game format: Y.MM.DD
use jomini::common::{UniformDate, PdsDate};
let date = UniformDate::from_ymd(1400, 1, 2);
assert_eq!(date.game_fmt().to_string(), String::from("1400.01.02"));
Auto Trait Implementations
impl RefUnwindSafe for UniformDate
impl Send for UniformDate
impl Sync for UniformDate
impl Unpin for UniformDate
impl UnwindSafe for UniformDate
Blanket Implementations
Mutably borrows from an owned value. Read more