pub struct FormattedTimeZone<'l, T>where
    T: TimeZoneInput,
{ /* private fields */ }
Expand description

FormattedTimeZone is a intermediate structure which can be retrieved as an output from TimeZoneFormatter.

Implementations

Write time zone with no fallback.

Examples
use icu::datetime::time_zone::TimeZoneFormatter;
use icu::datetime::DateTimeError;
use icu::locid::locale;
use icu::timezone::CustomTimeZone;
use tinystr::tinystr;

let mut tzf = TimeZoneFormatter::try_new_unstable(
    &icu_testdata::unstable(),
    &locale!("en").into(),
    Default::default(),
)
.unwrap();
let mut buf = String::new();

let mut time_zone = "Z".parse::<CustomTimeZone>().unwrap();
time_zone.time_zone_id = Some(tinystr!(8, "gblon").into());

// There are no non-fallback formats enabled:
assert!(matches!(
    tzf.format(&time_zone).write_no_fallback(&mut buf),
    Err(DateTimeError::UnsupportedOptions)
));
assert!(buf.is_empty());

// Enable a non-fallback format:
tzf.load_generic_location_format(&icu_testdata::unstable())
    .unwrap();
assert!(matches!(
    tzf.format(&time_zone).write_no_fallback(&mut buf),
    Ok(Ok(_))
));
assert_eq!("London Time", buf);

// Errors still occur if the time zone is not supported:
buf.clear();
time_zone.time_zone_id = Some(tinystr!(8, "zzzzz").into());
assert!(matches!(
    tzf.format(&time_zone).write_no_fallback(&mut buf),
    Err(DateTimeError::UnsupportedOptions)
));

// Use the `Writable` trait instead to enable infallible formatting:
writeable::assert_writeable_eq!(tzf.format(&time_zone), "GMT");

Trait Implementations

Formats the value using the given formatter. Read more

Format time zone with fallbacks.

Write bytes and Part annotations to the given sink. Errors from the sink are bubbled up. The default implementation delegates to write_to, and doesn’t produce any Part annotations. Read more
Returns a hint for the number of UTF-8 bytes that will be written to the sink. Read more
Creates a new String with the data from this Writeable. Like ToString, but smaller and faster. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Adds separators according to the given SeparatorPolicy. Read more
Inserts a comma every three digits from the right. Read more
Inserts a space every three digits from the right. Read more
Inserts a period every three digits from the right. Read more
Inserts an underscore every three digits from the right. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.