forked from kageru/tracc
improve sum_as_str
This commit is contained in:
parent
84f13d1806
commit
1be551d4f5
|
@ -94,10 +94,10 @@ impl TimeSheet {
|
||||||
pub fn sum_as_str(&self) -> String {
|
pub fn sum_as_str(&self) -> String {
|
||||||
let total = self
|
let total = self
|
||||||
.times
|
.times
|
||||||
.windows(2)
|
.iter()
|
||||||
.fold(time::Duration::zero(), |total, ts| {
|
.map(|tp| tp.time)
|
||||||
let last = ts[0].time;
|
.tuple_windows()
|
||||||
let next = ts[1].time;
|
.fold(time::Duration::zero(), |total, (last, next)| {
|
||||||
total + (next - last)
|
total + (next - last)
|
||||||
});
|
});
|
||||||
format_duration(&total)
|
format_duration(&total)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user