-
Notifications
You must be signed in to change notification settings - Fork 547
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Forked at: aaee912 Parent branch: chronotope/main
- Loading branch information
Showing
2 changed files
with
50 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,28 @@ | ||
#[cfg(feature = "locales")] | ||
mod with_locales { | ||
use super::super::{FormatError, FormatErrorKind, FormatResult}; | ||
|
||
macro_rules! locale_match { | ||
($locale:expr => $($item:ident)::+) => {{ | ||
match $locale { | ||
"en_US" => Ok(pure_rust_locales::en_US::$($item)::+), | ||
"fr_BE" => Ok(pure_rust_locales::fr_BE::$($item)::+), | ||
// TODO: all the locales are available | ||
_ => Err(FormatError(FormatErrorKind::UnknownLocale)), | ||
} | ||
}} | ||
} | ||
|
||
pub(crate) fn short_months(locale: &str) -> FormatResult<&[&'static str]> { | ||
locale_match!(locale => LC_TIME::ABMON) | ||
} | ||
|
||
pub(crate) fn long_months(locale: &str) -> FormatResult<&[&'static str]> { | ||
locale_match!(locale => LC_TIME::MON) | ||
} | ||
|
||
pub(crate) fn short_weekdays(locale: &str) -> FormatResult<&[&'static str]> { | ||
locale_match!(locale => LC_TIME::ABDAY) | ||
} | ||
|
||
pub(crate) fn long_weekdays(locale: &str) -> FormatResult<&[&'static str]> { | ||
locale_match!(locale => LC_TIME::DAY) | ||
} | ||
use super::{FormatError, FormatErrorKind, FormatResult}; | ||
|
||
macro_rules! locale_match { | ||
($locale:expr => $($item:ident)::+) => {{ | ||
match $locale { | ||
"en_US" => Ok(pure_rust_locales::en_US::$($item)::+), | ||
"fr_BE" => Ok(pure_rust_locales::fr_BE::$($item)::+), | ||
// TODO: all the locales are available | ||
_ => Err(FormatError(FormatErrorKind::UnknownLocale)), | ||
} | ||
}} | ||
} | ||
|
||
#[cfg(not(feature = "locales"))] | ||
mod without_locales { | ||
use super::super::FormatResult; | ||
|
||
pub(crate) fn short_months(_locale: &str) -> FormatResult<&[&'static str]> { | ||
Ok(&["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]) | ||
} | ||
|
||
pub(crate) fn long_months(_locale: &str) -> FormatResult<&[&'static str]> { | ||
Ok(&[ | ||
"January", | ||
"February", | ||
"March", | ||
"April", | ||
"May", | ||
"June", | ||
"July", | ||
"August", | ||
"September", | ||
"October", | ||
"November", | ||
"December", | ||
]) | ||
} | ||
|
||
pub(crate) fn short_weekdays(_locale: &str) -> FormatResult<&[&'static str]> { | ||
Ok(&["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]) | ||
} | ||
pub(crate) fn short_months(locale: &str) -> FormatResult<&[&'static str]> { | ||
locale_match!(locale => LC_TIME::ABMON) | ||
} | ||
|
||
pub(crate) fn long_weekdays(_locale: &str) -> FormatResult<&[&'static str]> { | ||
Ok(&["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]) | ||
} | ||
pub(crate) fn long_months(locale: &str) -> FormatResult<&[&'static str]> { | ||
locale_match!(locale => LC_TIME::MON) | ||
} | ||
|
||
#[cfg(feature = "locales")] | ||
pub(crate) use self::with_locales::*; | ||
pub(crate) fn short_weekdays(locale: &str) -> FormatResult<&[&'static str]> { | ||
locale_match!(locale => LC_TIME::ABDAY) | ||
} | ||
|
||
#[cfg(not(feature = "locales"))] | ||
pub(crate) use self::without_locales::*; | ||
pub(crate) fn long_weekdays(locale: &str) -> FormatResult<&[&'static str]> { | ||
locale_match!(locale => LC_TIME::DAY) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters