-
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.
- Loading branch information
Showing
2 changed files
with
226 additions
and
15 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 |
---|---|---|
@@ -0,0 +1,203 @@ | ||
/// Locale is a locale | ||
#[derive(Debug, Clone, Copy, Default)] | ||
pub struct Locale { | ||
days: Days, | ||
months: Months, | ||
} | ||
|
||
impl Locale { | ||
/// Returns days | ||
pub fn days(&self) -> Days { | ||
self.days | ||
} | ||
|
||
/// Returns months | ||
pub fn months(&self) -> Months { | ||
self.months | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone, Copy)] | ||
pub struct Days { | ||
pub monday: Elem, | ||
pub tuesday: Elem, | ||
pub wednesday: Elem, | ||
pub thursday: Elem, | ||
pub friday: Elem, | ||
pub saturday: Elem, | ||
pub sunday: Elem, | ||
} | ||
|
||
impl Days { | ||
pub fn into_long_array(self) -> [&'static str; 7] { | ||
[ | ||
self.monday.long, | ||
self.tuesday.long, | ||
self.wednesday.long, | ||
self.thursday.long, | ||
self.friday.long, | ||
self.saturday.long, | ||
self.sunday.long, | ||
] | ||
} | ||
|
||
pub fn into_short_array(self) -> [&'static str; 7] { | ||
[ | ||
self.monday.short, | ||
self.tuesday.short, | ||
self.wednesday.short, | ||
self.thursday.short, | ||
self.friday.short, | ||
self.saturday.short, | ||
self.sunday.short, | ||
] | ||
} | ||
} | ||
|
||
impl Default for Days { | ||
fn default() -> Self { | ||
Days { | ||
monday: Elem { | ||
long: "Monday", | ||
short: "Mon", | ||
}, | ||
tuesday: Elem { | ||
long: "Tuesday", | ||
short: "Tue", | ||
}, | ||
wednesday: Elem { | ||
long: "Wednesday", | ||
short: "Wed", | ||
}, | ||
thursday: Elem { | ||
long: "Thursday", | ||
short: "Thu", | ||
}, | ||
friday: Elem { | ||
long: "Friday", | ||
short: "Fri", | ||
}, | ||
saturday: Elem { | ||
long: "Saturday", | ||
short: "Sat", | ||
}, | ||
sunday: Elem { | ||
long: "Sunday", | ||
short: "Sun", | ||
}, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone, Copy)] | ||
pub struct Months { | ||
pub january: Elem, | ||
pub february: Elem, | ||
pub march: Elem, | ||
pub april: Elem, | ||
pub may: Elem, | ||
pub june: Elem, | ||
pub july: Elem, | ||
pub august: Elem, | ||
pub september: Elem, | ||
pub october: Elem, | ||
pub november: Elem, | ||
pub december: Elem, | ||
} | ||
|
||
impl Months { | ||
pub fn into_long_array(self) -> [&'static str; 12] { | ||
[ | ||
self.january.long, | ||
self.february.long, | ||
self.march.long, | ||
self.april.long, | ||
self.may.long, | ||
self.june.long, | ||
self.july.long, | ||
self.august.long, | ||
self.september.long, | ||
self.october.long, | ||
self.november.long, | ||
self.december.long, | ||
] | ||
} | ||
|
||
pub fn into_short_array(self) -> [&'static str; 12] { | ||
[ | ||
self.january.short, | ||
self.february.short, | ||
self.march.short, | ||
self.april.short, | ||
self.may.short, | ||
self.june.short, | ||
self.july.short, | ||
self.august.short, | ||
self.september.short, | ||
self.october.short, | ||
self.november.short, | ||
self.december.short, | ||
] | ||
} | ||
} | ||
|
||
impl Default for Months { | ||
fn default() -> Self { | ||
Months { | ||
january: Elem { | ||
long: "January", | ||
short: "Jan", | ||
}, | ||
february: Elem { | ||
long: "February", | ||
short: "Feb", | ||
}, | ||
march: Elem { | ||
long: "March", | ||
short: "Mar", | ||
}, | ||
april: Elem { | ||
long: "April", | ||
short: "Apr", | ||
}, | ||
may: Elem { | ||
long: "May", | ||
short: "May", | ||
}, | ||
june: Elem { | ||
long: "June", | ||
short: "Jun", | ||
}, | ||
july: Elem { | ||
long: "July", | ||
short: "Jul", | ||
}, | ||
august: Elem { | ||
long: "August", | ||
short: "Aug", | ||
}, | ||
september: Elem { | ||
long: "September", | ||
short: "Sep", | ||
}, | ||
october: Elem { | ||
long: "October", | ||
short: "Oct", | ||
}, | ||
november: Elem { | ||
long: "November", | ||
short: "Nov", | ||
}, | ||
december: Elem { | ||
long: "December", | ||
short: "Dec", | ||
}, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone, Copy)] | ||
pub struct Elem { | ||
long: &'static str, | ||
short: &'static str, | ||
} |
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