feat: current-time.rs
This commit is contained in:
@@ -18,6 +18,9 @@ struct Args {
|
|||||||
/// Add time (e.g. 1s (second), 1m (minute), 1h (hour), 1d (day), 1M (month), 1y (year) )
|
/// Add time (e.g. 1s (second), 1m (minute), 1h (hour), 1d (day), 1M (month), 1y (year) )
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
add_time: Option<String>,
|
add_time: Option<String>,
|
||||||
|
/// Output format (e.g. millis (default), s|secs)
|
||||||
|
#[arg(short, long)]
|
||||||
|
output_format: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@@ -30,10 +33,16 @@ fn main() {
|
|||||||
let add_time_millis = parse_add_time(&args.add_time);
|
let add_time_millis = parse_add_time(&args.add_time);
|
||||||
let final_time_millis = current_time_millis as i128 + add_time_millis;
|
let final_time_millis = current_time_millis as i128 + add_time_millis;
|
||||||
|
|
||||||
|
let output_format = args.output_format.map(|f| f.to_lowercase());
|
||||||
|
let final_time = match output_format.as_deref() {
|
||||||
|
Some("s") | Some("secs") | Some("second") | Some("seconds") => final_time_millis / 1000,
|
||||||
|
_ => final_time_millis,
|
||||||
|
};
|
||||||
|
|
||||||
if args.new_line {
|
if args.new_line {
|
||||||
println!("{}", final_time_millis);
|
println!("{}", final_time);
|
||||||
} else {
|
} else {
|
||||||
print!("{}", final_time_millis);
|
print!("{}", final_time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
},
|
},
|
||||||
"current-time-rs": {
|
"current-time-rs": {
|
||||||
"script_name": "current-time-rs",
|
"script_name": "current-time-rs",
|
||||||
"script_length": 1866,
|
"script_length": 2226,
|
||||||
"script_sha256": "f8980ea63a050398eceeae0b75983066b5e07dd348f46c08156462e526f9271c"
|
"script_sha256": "a8fd149fd0c64cc0c9d4b4deddf7b14d755249d2355670391521d0c7d108d538"
|
||||||
},
|
},
|
||||||
"decrypt-rs": {
|
"decrypt-rs": {
|
||||||
"script_name": "decrypt-rs",
|
"script_name": "decrypt-rs",
|
||||||
|
|||||||
Reference in New Issue
Block a user