From cedbaf1b5c0aa42a21979b5c1e1efa2676031b05 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 2 Mar 2018 14:37:44 +0100 Subject: [PATCH] Add "daily" support --- bin/domain/imag-diary/src/create.rs | 7 +++++++ bin/domain/imag-diary/src/util.rs | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bin/domain/imag-diary/src/create.rs b/bin/domain/imag-diary/src/create.rs index ad85f561..148c4b5a 100644 --- a/bin/domain/imag-diary/src/create.rs +++ b/bin/domain/imag-diary/src/create.rs @@ -106,6 +106,13 @@ fn create_id_from_clispec(create: &ArgMatches, diaryname: &str, timed_type: Time }; match timed_type { + Timed::Daily => { + debug!("Creating daily-timed entry"); + get_hourly_id(create) + .with_hour(0) + .with_minute(0) + .with_second(0) + }, Timed::Hourly => { debug!("Creating hourly-timed entry"); get_hourly_id(create) diff --git a/bin/domain/imag-diary/src/util.rs b/bin/domain/imag-diary/src/util.rs index aeff186f..db56b7ca 100644 --- a/bin/domain/imag-diary/src/util.rs +++ b/bin/domain/imag-diary/src/util.rs @@ -33,6 +33,7 @@ pub fn get_diary_name(rt: &Runtime) -> Option { } pub enum Timed { + Daily, Hourly, Minutely, Secondly, @@ -63,7 +64,7 @@ pub fn get_diary_timed_config(rt: &Runtime, diary_name: &str) -> Result parse_timed_string(s, diary_name).map(Some), Ok(Some(_)) => { - let s = format!("Type error at 'diary.diaryies.{}.timed': should be either 'h'/'hourly' or 'm'/'minutely'", diary_name); + let s = format!("Type error at 'diary.diaryies.{}.timed': should be either 'd'/'daily', 'h'/'hourly', 'm'/'minutely' or 's'/'secondly'", diary_name); Err(s).map_err(From::from) }, @@ -75,7 +76,9 @@ pub fn get_diary_timed_config(rt: &Runtime, diary_name: &str) -> Result Result { - if s == "h" || s == "hourly" { + if s == "d" || s == "daily" { + Ok(Timed::Daily) + } else if s == "h" || s == "hourly" { Ok(Timed::Hourly) } else if s == "m" || s == "minutely" { Ok(Timed::Minutely)