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
fn game_fmt(&self) -> PdsDateFormatter
fn game_fmt(&self) -> PdsDateFormatter
Formats the date in the game format
fn iso_8601(&self) -> PdsDateFormatter
fn iso_8601(&self) -> PdsDateFormatter
Formats the date in an iso8601 format
Implementations on Foreign Types
sourceimpl PdsDate for UniformDate
impl PdsDate for UniformDate
sourcepub fn year(&self) -> i16
pub fn year(&self) -> i16
Year of the date
use jomini::common::{UniformDate, PdsDate};
let date = UniformDate::from_ymd(1444, 2, 3);
assert_eq!(date.year(), 1444);
sourcepub fn month(&self) -> u8
pub fn month(&self) -> u8
Month of the date
use jomini::common::{UniformDate, PdsDate};
let date = UniformDate::from_ymd(1444, 2, 3);
assert_eq!(date.month(), 2);
sourcepub fn day(&self) -> u8
pub fn day(&self) -> u8
Day of the date
use jomini::common::{UniformDate, PdsDate};
let date = UniformDate::from_ymd(1444, 2, 3);
assert_eq!(date.day(), 3);
sourcepub fn iso_8601(&self) -> PdsDateFormatter
pub fn iso_8601(&self) -> PdsDateFormatter
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"));
sourcepub fn game_fmt(&self) -> PdsDateFormatter
pub fn game_fmt(&self) -> PdsDateFormatter
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"));
sourceimpl PdsDate for DateHour
impl PdsDate for DateHour
sourcepub fn year(&self) -> i16
pub fn year(&self) -> i16
Year of the date
use jomini::common::{DateHour, PdsDate};
let date = DateHour::from_ymdh(1936, 1, 2, 24);
assert_eq!(date.year(), 1936);
sourcepub fn month(&self) -> u8
pub fn month(&self) -> u8
Month of the date
use jomini::common::{DateHour, PdsDate};
let date = DateHour::from_ymdh(1936, 1, 2, 24);
assert_eq!(date.month(), 1);
sourcepub fn day(&self) -> u8
pub fn day(&self) -> u8
Day of the date
use jomini::common::{DateHour, PdsDate};
let date = DateHour::from_ymdh(1936, 1, 2, 24);
assert_eq!(date.day(), 2);
sourcepub fn iso_8601(&self) -> PdsDateFormatter
pub fn iso_8601(&self) -> PdsDateFormatter
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());
sourcepub fn game_fmt(&self) -> PdsDateFormatter
pub fn game_fmt(&self) -> PdsDateFormatter
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());