diff options
author | Andrew Walbran <qwandor@google.com> | 2024-02-21 17:10:36 +0000 |
---|---|---|
committer | Andrew Walbran <qwandor@google.com> | 2024-03-21 18:01:29 +0000 |
commit | c0dc6153e65acbd4b59926eaccf67cefa1bc6c5a (patch) | |
tree | 66b64b0104978d06a3dc21f73e3dc97ff024514a /src/format/locales.rs | |
parent | 894d6ced8fe0e14fd3867562e978fadec89ad94e (diff) | |
download | chrono-c0dc6153e65acbd4b59926eaccf67cefa1bc6c5a.tar.gz |
Upgrade chrono to 0.4.34
This project was upgraded with external_updater.
Usage: tools/external_updater/updater.sh update external/rust/crates/chrono
For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md
Bug: 326256145
Test: TreeHugger
Change-Id: Ibaddaa66db364a9d9d86be6f6cea06f3d57ba6d1
Diffstat (limited to 'src/format/locales.rs')
-rw-r--r-- | src/format/locales.rs | 116 |
1 files changed, 93 insertions, 23 deletions
diff --git a/src/format/locales.rs b/src/format/locales.rs index f7b4bbd..4cf4d41 100644 --- a/src/format/locales.rs +++ b/src/format/locales.rs @@ -1,33 +1,103 @@ -use pure_rust_locales::{locale_match, Locale}; +#[cfg(feature = "unstable-locales")] +mod localized { + use pure_rust_locales::{locale_match, Locale}; -pub(crate) fn short_months(locale: Locale) -> &'static [&'static str] { - locale_match!(locale => LC_TIME::ABMON) -} + pub(crate) const fn default_locale() -> Locale { + Locale::POSIX + } -pub(crate) fn long_months(locale: Locale) -> &'static [&'static str] { - locale_match!(locale => LC_TIME::MON) -} + pub(crate) const fn short_months(locale: Locale) -> &'static [&'static str] { + locale_match!(locale => LC_TIME::ABMON) + } -pub(crate) fn short_weekdays(locale: Locale) -> &'static [&'static str] { - locale_match!(locale => LC_TIME::ABDAY) -} + pub(crate) const fn long_months(locale: Locale) -> &'static [&'static str] { + locale_match!(locale => LC_TIME::MON) + } -pub(crate) fn long_weekdays(locale: Locale) -> &'static [&'static str] { - locale_match!(locale => LC_TIME::DAY) -} + pub(crate) const fn short_weekdays(locale: Locale) -> &'static [&'static str] { + locale_match!(locale => LC_TIME::ABDAY) + } -pub(crate) fn am_pm(locale: Locale) -> &'static [&'static str] { - locale_match!(locale => LC_TIME::AM_PM) -} + pub(crate) const fn long_weekdays(locale: Locale) -> &'static [&'static str] { + locale_match!(locale => LC_TIME::DAY) + } -pub(crate) fn d_fmt(locale: Locale) -> &'static str { - locale_match!(locale => LC_TIME::D_FMT) -} + pub(crate) const fn am_pm(locale: Locale) -> &'static [&'static str] { + locale_match!(locale => LC_TIME::AM_PM) + } + + pub(crate) const fn decimal_point(locale: Locale) -> &'static str { + locale_match!(locale => LC_NUMERIC::DECIMAL_POINT) + } + + pub(crate) const fn d_fmt(locale: Locale) -> &'static str { + locale_match!(locale => LC_TIME::D_FMT) + } + + pub(crate) const fn d_t_fmt(locale: Locale) -> &'static str { + locale_match!(locale => LC_TIME::D_T_FMT) + } + + pub(crate) const fn t_fmt(locale: Locale) -> &'static str { + locale_match!(locale => LC_TIME::T_FMT) + } -pub(crate) fn d_t_fmt(locale: Locale) -> &'static str { - locale_match!(locale => LC_TIME::D_T_FMT) + pub(crate) const fn t_fmt_ampm(locale: Locale) -> &'static str { + locale_match!(locale => LC_TIME::T_FMT_AMPM) + } } -pub(crate) fn t_fmt(locale: Locale) -> &'static str { - locale_match!(locale => LC_TIME::T_FMT) +#[cfg(feature = "unstable-locales")] +pub(crate) use localized::*; +#[cfg(feature = "unstable-locales")] +pub use pure_rust_locales::Locale; + +#[cfg(not(feature = "unstable-locales"))] +mod unlocalized { + #[derive(Copy, Clone, Debug)] + pub(crate) struct Locale; + + pub(crate) const fn default_locale() -> Locale { + Locale + } + + pub(crate) const fn short_months(_locale: Locale) -> &'static [&'static str] { + &["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] + } + + pub(crate) const fn long_months(_locale: Locale) -> &'static [&'static str] { + &[ + "January", + "February", + "March", + "April", + "May", + "June", + "July", + "August", + "September", + "October", + "November", + "December", + ] + } + + pub(crate) const fn short_weekdays(_locale: Locale) -> &'static [&'static str] { + &["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] + } + + pub(crate) const fn long_weekdays(_locale: Locale) -> &'static [&'static str] { + &["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] + } + + pub(crate) const fn am_pm(_locale: Locale) -> &'static [&'static str] { + &["AM", "PM"] + } + + pub(crate) const fn decimal_point(_locale: Locale) -> &'static str { + "." + } } + +#[cfg(not(feature = "unstable-locales"))] +pub(crate) use unlocalized::*; |