diff options
Diffstat (limited to 'src/utils/dateutil.rs')
-rw-r--r-- | src/utils/dateutil.rs | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/src/utils/dateutil.rs b/src/utils/dateutil.rs index bc70c02..7d3146a 100644 --- a/src/utils/dateutil.rs +++ b/src/utils/dateutil.rs @@ -59,7 +59,7 @@ pub fn now() -> DateTime<Utc> { *crate::testing::data::NOW_TEST } -pub fn week_from_str_end(date_str: &str) -> Result<Date<Local>, String> { +fn week_from_str_end(date_str: &str) -> Result<Date<Local>, String> { let now = Local::now(); if date_str == "toweek" || date_str == "thisweek" { return Ok(Local.isoywd(now.year(), now.iso_week().week(), Weekday::Sun)); @@ -75,13 +75,6 @@ pub fn week_from_str_end(date_str: &str) -> Result<Date<Local>, String> { Err("Could not parse '{}' as week".to_string()) } -pub fn datetime_from_timestamp(timestamp: &str) -> Option<DateTime<Local>> { - let timestamp_i64 = timestamp.parse::<i64>().ok()?; - let naive_datetime = NaiveDateTime::from_timestamp_opt(timestamp_i64, 0)?; - let utc_time: DateTime<Utc> = DateTime::from_utc(naive_datetime, Utc); - Some(utc_time.with_timezone(&Local)) -} - #[cfg(test)] mod tests { use super::*; @@ -141,11 +134,4 @@ mod tests { week_from_str_end("nonsense").unwrap(); } - #[test] - fn test_datetime_from_timestamp() { - let timestamp = "1547234687"; - let dt_from_ts = datetime_from_timestamp(timestamp).unwrap(); - let dt = Utc.ymd(2019, 01, 11).and_hms(19, 24, 47); - assert_eq!(dt, dt_from_ts); - } } |