fix: fill of elapsed time, remove local
var
Signed-off-by: Christina Sørensen <christina@cafkafk.com>
This commit is contained in:
parent
c76f17a51e
commit
4ec9a36d07
1 changed files with 6 additions and 5 deletions
11
src/main.rs
11
src/main.rs
|
@ -12,20 +12,21 @@ fn main() -> io::Result<()> {
|
||||||
|
|
||||||
let time_only = NaiveTime::parse_from_str(&buffer, "%H:%M:%S").unwrap();
|
let time_only = NaiveTime::parse_from_str(&buffer, "%H:%M:%S").unwrap();
|
||||||
|
|
||||||
let local: DateTime<Local> = Local::now();
|
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"delta: \t\t{time_only} -> {}",
|
"delta: \t\t{time_only} -> {}",
|
||||||
local.time().format("%H:%M:%S").to_string()
|
Local::now().time().format("%H:%M:%S").to_string()
|
||||||
);
|
);
|
||||||
|
|
||||||
let dt = NaiveTime::signed_duration_since(local.time(), time_only);
|
let dt = NaiveTime::signed_duration_since(Local::now().time(), time_only);
|
||||||
|
|
||||||
let hours = (dt.num_seconds() / 60) / 60;
|
let hours = (dt.num_seconds() / 60) / 60;
|
||||||
let minutes = (dt.num_seconds() / 60) % 60;
|
let minutes = (dt.num_seconds() / 60) % 60;
|
||||||
let seconds = dt.num_seconds() % 60;
|
let seconds = dt.num_seconds() % 60;
|
||||||
|
|
||||||
println!("elapsed: \t{}:{}:{}", &hours, &minutes, &seconds);
|
println!(
|
||||||
|
"elapsed: \t{:0>2.}:{:0>2.}:{:0>2.}",
|
||||||
|
&hours, &minutes, &seconds
|
||||||
|
);
|
||||||
|
|
||||||
let total = format!("{}.{:.0}", &hours, 100. / 60. * minutes as f32)
|
let total = format!("{}.{:.0}", &hours, 100. / 60. * minutes as f32)
|
||||||
.parse::<f64>()
|
.parse::<f64>()
|
||||||
|
|
Loading…
Reference in a new issue