diff --git a/src/main.rs b/src/main.rs index ad08607..29397f3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,7 @@ use std::fs::File; use std::time::{SystemTime, UNIX_EPOCH, Duration}; use std::ops::{Add, Sub}; use clap::Parser; -use chrono::DateTime; +use chrono::{TimeZone, Local}; #[derive(Debug, Parser)] struct Flags { @@ -108,13 +108,11 @@ fn parse_time(since: &Option) -> Result { match since { Some(since) => { match chrono::NaiveDate::parse_from_str(since, "%Y-%m-%d") { - Ok(dt) => { + Ok(nd) => { + let ndt = nd.and_hms_opt(1, 1, 1).unwrap(); + let dt = Local.from_local_datetime(&ndt).unwrap(); Ok(UNIX_EPOCH.add( - Duration::from_secs( - dt.and_hms_opt(1, 1, 1) - .unwrap() - .timestamp() as u64 - ) + Duration::from_secs(dt.timestamp() as u64) )) }, Err(msg) => Err(format!("failed to parse {}: {}", since, msg)),