diff options
author | dfhoughton <dfhoughton@gmail.com> | 2019-01-20 13:47:09 -0500 |
---|---|---|
committer | dfhoughton <dfhoughton@gmail.com> | 2019-01-20 13:47:09 -0500 |
commit | 63cffe10d36371298486dfe611b003153c6bf561 (patch) | |
tree | a4e6926f93fc442e0c5ba733bb65a125513af0e2 /src | |
parent | d3fa93c177c650edd01c0e729f2f9da86c355ee5 (diff) | |
download | two-timer-63cffe10d36371298486dfe611b003153c6bf561.zip |
fixed regression
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -972,14 +972,19 @@ fn time(m: &Match) -> (u32, Option<u32>, Option<u32>) { 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!() |