diff --git a/wayshot/Cargo.toml b/wayshot/Cargo.toml index 9364ff88..3a111f26 100644 --- a/wayshot/Cargo.toml +++ b/wayshot/Cargo.toml @@ -32,6 +32,7 @@ image = { version = "0.24", default-features = false, features = [ dialoguer = { version = "0.11.0", features = ["fuzzy-select"] } eyre = "0.6.8" +chrono = "0.4.35" wl-clipboard-rs = "0.8.0" nix = { version = "0.28.0", features = ["process"] } diff --git a/wayshot/src/utils.rs b/wayshot/src/utils.rs index 117c1f0c..158f997f 100644 --- a/wayshot/src/utils.rs +++ b/wayshot/src/utils.rs @@ -1,13 +1,9 @@ use clap::ValueEnum; use eyre::{bail, ContextCompat, Error, Result}; -use std::{ - fmt::Display, - path::PathBuf, - str::FromStr, - time::{SystemTime, UNIX_EPOCH}, -}; +use std::{fmt::Display, path::PathBuf, str::FromStr}; +use chrono::{DateTime, Local}; use libwayshot::region::{LogicalRegion, Position, Region, Size}; pub fn parse_geometry(g: &str) -> Result { @@ -134,10 +130,8 @@ impl FromStr for EncodingFormat { } pub fn get_default_file_name(extension: EncodingFormat) -> PathBuf { - let time = SystemTime::now() - .duration_since(UNIX_EPOCH) - .map(|time| time.as_secs().to_string()) - .unwrap_or("unknown".into()); + let current_datetime: DateTime = Local::now(); + let formated_time = format!("{}", current_datetime.format("%Y_%m_%d-%H_%M_%S")); - format!("{time}-wayshot.{extension}").into() + format!("wayshot-{formated_time}.{extension}").into() }