summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authordfhoughton <dfhoughton@gmail.com>2019-01-20 13:47:09 -0500
committerdfhoughton <dfhoughton@gmail.com>2019-01-20 13:47:09 -0500
commit63cffe10d36371298486dfe611b003153c6bf561 (patch)
treea4e6926f93fc442e0c5ba733bb65a125513af0e2 /src/lib.rs
parentd3fa93c177c650edd01c0e729f2f9da86c355ee5 (diff)
downloadtwo-timer-63cffe10d36371298486dfe611b003153c6bf561.zip
fixed regression
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs9
1 files changed, 7 insertions, 2 deletions
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<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!()