From 5152ced2f13a751bcfa981f29ccf0d0dea2d4040 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Sun, 8 Jul 2018 21:31:18 -0400 Subject: [PATCH] One last test case, then version 0.9! --- src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 695667f..422b597 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -196,7 +196,9 @@ impl ParserInfo { fn get_ampm(&self, name: &str) -> Option { if let Some(v) = self.ampm.get(&name.to_lowercase()) { - Some(v.to_owned() == 1) + // Python technically uses numbers here, but given that the numbers are + // only 0 and 1, it's easier to use booleans + Some(*v == 1) } else { None } @@ -639,7 +641,7 @@ impl Parser { let is_ampm = self.ampm_valid(res.hour, res.ampm, fuzzy); if is_ampm.is_ok() { - res.hour = Some(self.adjust_ampm(res.hour.unwrap(), value)); + res.hour = res.hour.map(|h| self.adjust_ampm(h, value)); res.ampm = Some(value); } else if fuzzy { skipped_idxs.push(i);