oooo tests pass

master
Bel LaPointe 2024-05-15 22:56:40 -04:00
parent a627223e8a
commit 4f4e7fd907
1 changed files with 7 additions and 3 deletions

View File

@ -77,12 +77,13 @@ impl When {
_ => {}, _ => {},
}; };
match TS::new(self.0.clone()) { match TS::new(self.0.clone()) {
Ok(ts) => { return ts; }, Ok(ts) => {
return ts;
},
_ => {}, _ => {},
}; };
match Cron::new(self.0.clone()) { match Cron::new(self.0.clone()) {
Ok(x) => { Ok(x) => {
eprintln!("cron::new({:?}) => {:?}", self.0.clone(), x.clone());
return x.next(now); return x.next(now);
}, },
_ => {}, _ => {},
@ -180,7 +181,10 @@ struct Duration(u64);
impl Duration { impl Duration {
fn new(src: String) -> Result<Duration, String> { fn new(src: String) -> Result<Duration, String> {
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) { match duration.is_match(&src) {
false => { return Err("ill formatted duration".to_string()); }, false => { return Err("ill formatted duration".to_string()); },
_ => {}, _ => {},