From 63cffe10d36371298486dfe611b003153c6bf561 Mon Sep 17 00:00:00 2001 From: dfhoughton Date: Sun, 20 Jan 2019 13:47:09 -0500 Subject: fixed regression --- src/lib.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 3b345e7..c540152 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -972,14 +972,19 @@ fn time(m: &Match) -> (u32, Option, Option) { let hour = if let Some(hour_24) = m.name("hour_24") { s_to_n(hour_24.name("h24").unwrap().as_str()) } else if let Some(hour_12) = m.name("hour_12") { - let hour = s_to_n(hour_12.name("h12").unwrap().as_str()); - if let Some(am_pm) = m.name("am_pm") { + let mut hour = s_to_n(hour_12.name("h12").unwrap().as_str()); + hour = if let Some(am_pm) = m.name("am_pm") { match am_pm.as_str().chars().nth(0).expect("empty string") { 'a' | 'A' => hour, _ => hour + 12, } } else { hour + }; + if hour == 24 { + 0 + } else { + hour } } else { unreachable!() -- cgit v1.2.3