icu_locale_core/preferences/extensions/unicode/keywords/timezone.rs
1// This file is part of ICU4X. For terms of use, please see the file
2// called LICENSE at the top level of the ICU4X source tree
3// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4
5use crate::preferences::extensions::unicode::errors::PreferencesParseError;
6use crate::preferences::extensions::unicode::struct_keyword;
7use crate::{extensions::unicode::Value, subtags::Subtag};
8
9struct_keyword!(
10 /// A Unicode Timezone Identifier defines a timezone.
11 ///
12 /// The valid values are listed in [LDML](https://unicode.org/reports/tr35/#UnicodeTimezoneIdentifier).
13 [Copy]
14 TimeZoneShortId,
15 "tz",
16 Subtag,
17 |input: Value| {
18 input
19 .into_single_subtag()
20 .map(Self)
21 .ok_or(PreferencesParseError::InvalidKeywordValue)
22 },
23 |input: TimeZoneShortId| {
24 crate::extensions::unicode::Value::from_subtag(Some(input.0))
25 }
26);