--since as local timezone
parent
0f9711aaa1
commit
cf47c63bd7
12
src/main.rs
12
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<String>) -> Result<SystemTime, String> {
|
|||
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)),
|
||||
|
|
|
|||
Loading…
Reference in New Issue