/src/chrono/src/format/locales.rs
Line | Count | Source |
1 | | #[cfg(feature = "unstable-locales")] |
2 | | mod localized { |
3 | | use pure_rust_locales::{Locale, locale_match}; |
4 | | |
5 | | pub(crate) const fn default_locale() -> Locale { |
6 | | Locale::POSIX |
7 | | } |
8 | | |
9 | | pub(crate) const fn short_months(locale: Locale) -> &'static [&'static str] { |
10 | | locale_match!(locale => LC_TIME::ABMON) |
11 | | } |
12 | | |
13 | | pub(crate) const fn long_months(locale: Locale) -> &'static [&'static str] { |
14 | | locale_match!(locale => LC_TIME::MON) |
15 | | } |
16 | | |
17 | | pub(crate) const fn short_weekdays(locale: Locale) -> &'static [&'static str] { |
18 | | locale_match!(locale => LC_TIME::ABDAY) |
19 | | } |
20 | | |
21 | | pub(crate) const fn long_weekdays(locale: Locale) -> &'static [&'static str] { |
22 | | locale_match!(locale => LC_TIME::DAY) |
23 | | } |
24 | | |
25 | | pub(crate) const fn am_pm(locale: Locale) -> &'static [&'static str] { |
26 | | locale_match!(locale => LC_TIME::AM_PM) |
27 | | } |
28 | | |
29 | | pub(crate) const fn decimal_point(locale: Locale) -> &'static str { |
30 | | locale_match!(locale => LC_NUMERIC::DECIMAL_POINT) |
31 | | } |
32 | | |
33 | | pub(crate) const fn d_fmt(locale: Locale) -> &'static str { |
34 | | locale_match!(locale => LC_TIME::D_FMT) |
35 | | } |
36 | | |
37 | | pub(crate) const fn d_t_fmt(locale: Locale) -> &'static str { |
38 | | locale_match!(locale => LC_TIME::D_T_FMT) |
39 | | } |
40 | | |
41 | | pub(crate) const fn t_fmt(locale: Locale) -> &'static str { |
42 | | locale_match!(locale => LC_TIME::T_FMT) |
43 | | } |
44 | | |
45 | | pub(crate) const fn t_fmt_ampm(locale: Locale) -> &'static str { |
46 | | locale_match!(locale => LC_TIME::T_FMT_AMPM) |
47 | | } |
48 | | } |
49 | | |
50 | | #[cfg(feature = "unstable-locales")] |
51 | | pub(crate) use localized::*; |
52 | | #[cfg(feature = "unstable-locales")] |
53 | | pub use pure_rust_locales::Locale; |
54 | | |
55 | | #[cfg(not(feature = "unstable-locales"))] |
56 | | mod unlocalized { |
57 | | #[derive(Copy, Clone, Debug)] |
58 | | pub(crate) struct Locale; |
59 | | |
60 | 0 | pub(crate) const fn default_locale() -> Locale { |
61 | 0 | Locale |
62 | 0 | } |
63 | | |
64 | 0 | pub(crate) const fn short_months(_locale: Locale) -> &'static [&'static str] { |
65 | 0 | &["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] |
66 | 0 | } |
67 | | |
68 | 0 | pub(crate) const fn long_months(_locale: Locale) -> &'static [&'static str] { |
69 | 0 | &[ |
70 | 0 | "January", |
71 | 0 | "February", |
72 | 0 | "March", |
73 | 0 | "April", |
74 | 0 | "May", |
75 | 0 | "June", |
76 | 0 | "July", |
77 | 0 | "August", |
78 | 0 | "September", |
79 | 0 | "October", |
80 | 0 | "November", |
81 | 0 | "December", |
82 | 0 | ] |
83 | 0 | } |
84 | | |
85 | 0 | pub(crate) const fn short_weekdays(_locale: Locale) -> &'static [&'static str] { |
86 | 0 | &["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] |
87 | 0 | } |
88 | | |
89 | 0 | pub(crate) const fn long_weekdays(_locale: Locale) -> &'static [&'static str] { |
90 | 0 | &["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] |
91 | 0 | } |
92 | | |
93 | 0 | pub(crate) const fn am_pm(_locale: Locale) -> &'static [&'static str] { |
94 | 0 | &["AM", "PM"] |
95 | 0 | } |
96 | | |
97 | 0 | pub(crate) const fn decimal_point(_locale: Locale) -> &'static str { |
98 | 0 | "." |
99 | 0 | } |
100 | | } |
101 | | |
102 | | #[cfg(not(feature = "unstable-locales"))] |
103 | | pub(crate) use unlocalized::*; |