Debian Codegraph @

debian/rust-vendor/icu_datetime/tests/patterns/time_zones.rs

raw
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
5 use icu_datetime::fieldsets::{self, enums::ZoneFieldSet};
6 use serde::{Deserialize, Serialize};
7 use std::collections::HashMap;
8
9 #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10 pub struct TimeZoneTests(pub Vec<TimeZoneTest>);
11
12 #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
13 pub struct TimeZoneTest {
14 pub locale: String,
15 pub datetime: String,
16 pub expectations: HashMap<String, String>,
17 }
18
19 pub fn pattern_to_semantic_skeleton(p: &str) -> Option<ZoneFieldSet> {
20 Some(match p {
21 "vvvv" => ZoneFieldSet::GenericLong(fieldsets::zone::GenericLong),
22 "v" => ZoneFieldSet::GenericShort(fieldsets::zone::GenericShort),
23 "VVVV" => ZoneFieldSet::Location(fieldsets::zone::Location),
24 "zzzz" => ZoneFieldSet::SpecificLong(fieldsets::zone::SpecificLong),
25 "z" => ZoneFieldSet::SpecificShort(fieldsets::zone::SpecificShort),
26 "OOOO" => ZoneFieldSet::LocalizedOffsetLong(fieldsets::zone::LocalizedOffsetLong),
27 "O" => ZoneFieldSet::LocalizedOffsetShort(fieldsets::zone::LocalizedOffsetShort),
28 "VVV" => ZoneFieldSet::ExemplarCity(fieldsets::zone::ExemplarCity),
29 // ISO currently untested
30 "x" | "xx" | "xxx" | "xxxx" | "xxxxx" | "X" | "XX" | "XXX" | "XXXX" | "XXXXX" => {
31 return None;
32 }
33 _ => panic!("unhandled test {p}"),
34 })
35 }