summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
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!()