Struct hoi4save::Date[][src]

pub struct Date { /* fields omitted */ }

Struct specialized to parsing, formatting, and manipulating dates in games

A game date does not follow any traditional calendar and instead views the world on simpler terms: that every year should be treated as a non-leap year.

Implementations

impl Date[src]

pub fn new(year: i16, month: u8, day: u8, hour: u8) -> Option<Self>[src]

pub fn year(&self) -> i16[src]

Year of the date

pub fn month(&self) -> u8[src]

Month of the date

pub fn day(&self) -> u8[src]

Day of the date

pub fn hour(&self) -> u8[src]

Day of the date

pub fn parse_from_str<T: AsRef<str>>(s: T) -> Option<Self>[src]

Parses a string and returns a new Date if valid.

pub fn days_until(&self, other: &Date) -> i32[src]

Returns the number of days between two dates

pub fn add_days(&self, days: i32) -> Date[src]

Return a new date that is the given number of days in the future from the current date

Will panic on overflow or underflow.

pub fn from_binary(mut s: i32) -> Option<Self>[src]

Decodes a date from a number that had been parsed from binary data

pub fn iso_8601(&self) -> String[src]

Formats a date in the ISO 8601 format: YYYY-MM-DD

pub fn game_fmt(&self) -> String[src]

Formats a date in the game format: Y.M.D

Trait Implementations

impl Clone for Date[src]

impl Copy for Date[src]

impl Debug for Date[src]

impl<'de> Deserialize<'de> for Date[src]

impl Eq for Date[src]

impl Ord for Date[src]

impl PartialEq<Date> for Date[src]

impl PartialOrd<Date> for Date[src]

impl Serialize for Date[src]

impl StructuralEq for Date[src]

impl StructuralPartialEq for Date[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.