pub trait PdsDate {
    fn year(&self) -> i16;
fn month(&self) -> u8;
fn day(&self) -> u8;
fn game_fmt(&self) -> PdsDateFormatter;
fn iso_8601(&self) -> PdsDateFormatter; }
Expand description

Common set of methods between all the date components

Required methods

Return the year

Returns the month. Range: [1, 12]

Return the day

Formats the date in the game format

Formats the date in an iso8601 format

Implementations on Foreign Types

Year of the date

use jomini::common::{DateHour, PdsDate};
let date = DateHour::from_ymdh(1936, 1, 2, 24);
assert_eq!(date.year(), 1936);

Month of the date

use jomini::common::{DateHour, PdsDate};
let date = DateHour::from_ymdh(1936, 1, 2, 24);
assert_eq!(date.month(), 1);

Day of the date

use jomini::common::{DateHour, PdsDate};
let date = DateHour::from_ymdh(1936, 1, 2, 24);
assert_eq!(date.day(), 2);

Return the date as an iso8601 compatible string

The hour component is converted to a range of [0, 23] per the spec

use jomini::common::{DateHour, PdsDate};
let date = DateHour::from_ymdh(1936, 1, 2, 12);
assert_eq!(String::from("1936-01-02T11"), date.iso_8601().to_string());

Return the date in the game format

use jomini::common::{DateHour, PdsDate};
let date = DateHour::from_ymdh(1936, 1, 2, 12);
assert_eq!(String::from("1936.1.2.12"), date.game_fmt().to_string());

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"));

Return year of date

Return month of date

Return day of date

Implementors