aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index c4996f5..8f5f038 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -15,7 +15,6 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use chrono;
-use inflector::Inflector;
use serde_yaml;
use std::io::BufReader;
use std::iter::Iterator;
@@ -23,13 +22,20 @@ use std::fs::File;
use std::str::FromStr;
use std::string::ToString;
+fn capitalize(s: &str) -> String {
+ match s.chars().next() {
+ Some(ch) => ch.to_uppercase().collect::<String>() + &s[1..],
+ None => String::new(),
+ }
+}
+
fn print_entry(d: &serde_yaml::Value) {
let name = d.get("name").unwrap();
- println!("{}", name.as_str().unwrap().to_sentence_case());
+ println!("{}", capitalize(name.as_str().unwrap()));
if let Some(alt_names) = d.get("alternative_names") {
let names = alt_names.as_sequence().unwrap().iter()
- .map(|v| v.as_str().unwrap().to_title_case())
+ .map(|v| capitalize(v.as_str().unwrap()))
.collect::<Vec<_>>();
println!("({})", names.join(", "));
}
@@ -52,7 +58,7 @@ fn main() {
None => chrono::Local::today().naive_utc(),
};
- println!("{}", local_date.format("%A %d. %b, %Y"));
+ println!("{}", capitalize(&local_date.format("%A %d. %b, %Y").to_string()));
let key = local_date.format("%d%m").to_string();
match data.get(serde_yaml::Value::Number(u32::from_str(&key).unwrap().into())) {