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) )
|
||||
#[arg(short, long)]
|
||||
add_time: Option<String>,
|
||||
/// Output format (e.g. millis (default), s|secs)
|
||||
#[arg(short, long)]
|
||||
output_format: Option<String>,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@@ -30,10 +33,16 @@ fn main() {
|
||||
let add_time_millis = parse_add_time(&args.add_time);
|
||||
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 {
|
||||
println!("{}", final_time_millis);
|
||||
println!("{}", final_time);
|
||||
} else {
|
||||
print!("{}", final_time_millis);
|
||||
print!("{}", final_time);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user