diff options
Diffstat (limited to 'src/utils/dateutil.rs')
-rw-r--r-- | src/utils/dateutil.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/utils/dateutil.rs b/src/utils/dateutil.rs index 1272834..7b7c1dc 100644 --- a/src/utils/dateutil.rs +++ b/src/utils/dateutil.rs @@ -22,6 +22,17 @@ pub fn week_from_str_begin(date_str: &str) -> Result<Date<Local>,String> { Err("Could not parse '{}' as week".to_string()) } +#[cfg(not(test))] +pub fn now() -> DateTime<Utc> { + Utc::now() +} + +#[cfg(test)] +pub fn now() -> DateTime<Utc> { + use testdata; + *testdata::now_test +} + pub fn week_from_str_end(date_str: &str) -> Result<Date<Local>,String> { let now = Local::now(); if date_str == "toweek" || date_str == "thisweek" { |