spreadsheet_ods/locale/
en_us.rs1use crate::defaultstyles::DefaultFormat;
2use crate::format::FormatNumberStyle;
3use crate::locale::LocalizedValueFormat;
4use crate::{
5 ValueFormatBoolean, ValueFormatCurrency, ValueFormatDateTime, ValueFormatNumber,
6 ValueFormatPercentage, ValueFormatTimeDuration,
7};
8use icu_locale_core::{locale, Locale};
9
10pub(crate) struct LocaleEnUs {}
11
12pub(crate) static LOCALE_EN_US: LocaleEnUs = LocaleEnUs {};
13
14impl LocaleEnUs {
15 const LOCALE: Locale = locale!("en-US");
16}
17
18impl LocalizedValueFormat for LocaleEnUs {
19 fn locale(&self) -> Locale {
20 LocaleEnUs::LOCALE
21 }
22
23 fn boolean_format(&self) -> ValueFormatBoolean {
24 let mut v = ValueFormatBoolean::new_localized(DefaultFormat::bool(), Self::LOCALE);
25 v.part_boolean().build();
26 v
27 }
28
29 fn number_format(&self) -> ValueFormatNumber {
30 let mut v = ValueFormatNumber::new_localized(DefaultFormat::number(), Self::LOCALE);
31 v.part_number()
32 .min_integer_digits(1)
33 .decimal_places(2)
34 .build();
35 v
36 }
37
38 fn percentage_format(&self) -> ValueFormatPercentage {
39 let mut v = ValueFormatPercentage::new_localized(DefaultFormat::percent(), Self::LOCALE);
40 v.part_number()
41 .min_integer_digits(1)
42 .decimal_places(2)
43 .build();
44 v.part_text("%").build();
45 v
46 }
47
48 fn currency_format(&self) -> ValueFormatCurrency {
49 let mut v = ValueFormatCurrency::new_localized(DefaultFormat::currency(), Self::LOCALE);
50 v.part_currency().locale(Self::LOCALE).symbol("$").build();
51 v.part_text(" ").build();
52 v.part_number()
53 .min_integer_digits(1)
54 .decimal_places(2)
55 .min_decimal_places(2)
56 .grouping()
57 .build();
58 v
59 }
60
61 fn date_format(&self) -> ValueFormatDateTime {
62 let mut v = ValueFormatDateTime::new_localized(DefaultFormat::date(), Self::LOCALE);
63 v.part_month().style(FormatNumberStyle::Long).build();
64 v.part_text("/").build();
65 v.part_day().style(FormatNumberStyle::Long).build();
66 v.part_text("/").build();
67 v.part_year().style(FormatNumberStyle::Long).build();
68 v
69 }
70
71 fn datetime_format(&self) -> ValueFormatDateTime {
72 let mut v = ValueFormatDateTime::new_localized(DefaultFormat::datetime(), Self::LOCALE);
73 v.part_day().style(FormatNumberStyle::Long).build();
74 v.part_text(".").build();
75 v.part_month().style(FormatNumberStyle::Long).build();
76 v.part_text(".").build();
77 v.part_year().style(FormatNumberStyle::Long).build();
78 v.part_text(" ").build();
79 v.part_hours().style(FormatNumberStyle::Long).build();
80 v.part_text(":").build();
81 v.part_minutes().style(FormatNumberStyle::Long).build();
82 v.part_text(":").build();
83 v.part_seconds().style(FormatNumberStyle::Long).build();
84 v
85 }
86
87 fn time_of_day_format(&self) -> ValueFormatDateTime {
88 let mut v = ValueFormatDateTime::new_localized(DefaultFormat::time_of_day(), Self::LOCALE);
89 v.part_hours().style(FormatNumberStyle::Long).build();
90 v.part_text(":").build();
91 v.part_minutes().style(FormatNumberStyle::Long).build();
92 v.part_text(":").build();
93 v.part_seconds().style(FormatNumberStyle::Long).build();
94 v.part_text(" ").build();
95 v.part_am_pm().build();
96 v
97 }
98
99 fn time_interval_format(&self) -> ValueFormatTimeDuration {
100 let mut v =
101 ValueFormatTimeDuration::new_localized(DefaultFormat::time_interval(), Self::LOCALE);
102 v.set_truncate_on_overflow(false);
103
104 v.part_hours().style(FormatNumberStyle::Long).build();
105 v.part_text(":").build();
106 v.part_minutes().style(FormatNumberStyle::Long).build();
107 v.part_text(":").build();
108 v.part_seconds().style(FormatNumberStyle::Long).build();
109 v
110 }
111}