diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2018-12-25 17:44:20 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2018-12-25 17:44:20 +0100 |
commit | b1bd3488795a9e3788e26092452706205ecf2ee5 (patch) | |
tree | 14029ce2149b534e9182980a9b5c7cc6695258e4 /src/main.rs | |
parent | 35507bfecf829fa1cc9166d0f1cfe9249ffed92b (diff) | |
download | primstav-b1bd3488795a9e3788e26092452706205ecf2ee5.tar.gz primstav-b1bd3488795a9e3788e26092452706205ecf2ee5.tar.bz2 primstav-b1bd3488795a9e3788e26092452706205ecf2ee5.zip |
Add a simplistic locale module.
For now only handles formatting the date string. Not sure how I will
provide for different date formats, as the format string has to be a
static string literal and can't be passed in from a variable. Would
probably be better to interface the locale functionality of the OS
instead.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 8f5f038..8804dc7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,6 +22,8 @@ use std::fs::File; use std::str::FromStr; use std::string::ToString; +mod locale; + fn capitalize(s: &str) -> String { match s.chars().next() { Some(ch) => ch.to_uppercase().collect::<String>() + &s[1..], @@ -58,7 +60,7 @@ fn main() { None => chrono::Local::today().naive_utc(), }; - println!("{}", capitalize(&local_date.format("%A %d. %b, %Y").to_string())); + println!("{}", capitalize(&locale::NB.format_date(&local_date))); let key = local_date.format("%d%m").to_string(); match data.get(serde_yaml::Value::Number(u32::from_str(&key).unwrap().into())) { |