Skip to main content

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            .as_single_subtag()
20            .copied()
21            .map(Self)
22            .ok_or(PreferencesParseError::InvalidKeywordValue)
23    },
24    |input: &TimeZoneShortId| {
25        Value::from_subtag(Some(input.0))
26    }
27);