From 4f4e7fd907a0f2c154f692d1d814b0f3b7fcf356 Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Wed, 15 May 2024 22:56:40 -0400 Subject: [PATCH] oooo tests pass --- pttodoer/src/main.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pttodoer/src/main.rs b/pttodoer/src/main.rs index 27f6afd..8ffe24c 100644 --- a/pttodoer/src/main.rs +++ b/pttodoer/src/main.rs @@ -77,12 +77,13 @@ impl When { _ => {}, }; match TS::new(self.0.clone()) { - Ok(ts) => { return ts; }, + Ok(ts) => { + return ts; + }, _ => {}, }; match Cron::new(self.0.clone()) { Ok(x) => { - eprintln!("cron::new({:?}) => {:?}", self.0.clone(), x.clone()); return x.next(now); }, _ => {}, @@ -180,7 +181,10 @@ struct Duration(u64); impl Duration { fn new(src: String) -> Result { - let duration = Regex::new(r"([0-9]+d)?([0-9]+h)?([0-9]+m)?").unwrap(); + if src.len() == 0 { + return Err("no empty duration".to_string()); + } + let duration = Regex::new(r"^([0-9]+d)?([0-9]+h)?([0-9]+m)?$").unwrap(); match duration.is_match(&src) { false => { return Err("ill formatted duration".to_string()); }, _ => {},