Type Alias icu::datetime::fieldset::YMDTZ

source ·
pub type YMDTZ = Combo<YMDT, Zs>;
Expand description

“17 May 2024, 15:47:50 BST” ⇒ locale-dependent date and time fields with a time zone

§Examples

In DateTimeFormatter:

use icu::calendar::{Date, Time};
use icu::timezone::{TimeZoneInfo, IxdtfParser};
use icu::datetime::DateTimeFormatter;
use icu::datetime::fieldset::YMDTZ;
use icu::locale::locale;
use writeable::assert_try_writeable_eq;

let fmt = DateTimeFormatter::try_new(
    &locale!("en-GB").into(),
    YMDTZ::medium(),
)
.unwrap();

let mut dtz = IxdtfParser::new().try_from_str("2024-05-17T15:47:50+01:00[Europe/London]").unwrap();

assert_try_writeable_eq!(
    fmt.convert_and_format(&dtz),
    "17 May 2024, 15:47:50 BST"
);

In FixedCalendarDateTimeFormatter:

use icu::calendar::{Date, Time};
use icu::timezone::{TimeZoneInfo, IxdtfParser};
use icu::calendar::Gregorian;
use icu::datetime::FixedCalendarDateTimeFormatter;
use icu::datetime::fieldset::YMDTZ;
use icu::locale::locale;
use writeable::assert_try_writeable_eq;

let fmt = FixedCalendarDateTimeFormatter::<Gregorian, YMDTZ>::try_new(
    &locale!("en-GB").into(),
    YMDTZ::medium(),
)
.unwrap();

let mut dtz = IxdtfParser::new().try_from_str("2024-05-17T15:47:50+01:00[Europe/London]")
    .unwrap()
    .to_calendar(Gregorian);

assert_try_writeable_eq!(
    fmt.format(&dtz),
    "17 May 2024, 15:47:50 BST"
);

Aliased Type§

struct YMDTZ { /* private fields */ }