pub fn spent_time(&self) -> Duration {
    let (spent, last_wip) =
      self
        .history
        .iter()
        .fold((Duration::zero(), None), |(spent, last_wip), event| {
          match event {
            Event::StatusChanged { event_date, status } => match (status, last_wip) {
              // We go from any status to WIP status; return the spent time untouched and set the new “last_wip” with the
              // time at which the status change occurred
              (Status::Ongoing, _) => (spent, Some(event_date.clone())),
              // We go to anything but WIP while the previous status was WIP; accumulate.
              (_, Some(last_wip)) => (spent + (event_date.signed_duration_since(last_wip)), None),
              // We go between inactive status, ignore
              _ => (spent, last_wip),
            },
            _ => (spent, last_wip),
          }
        });

    if let Some(last_wip) = last_wip {
      // last status was WIP; accumulate moaaar
      spent + Utc::now().signed_duration_since(last_wip)
    } else {
      spent
    }
  }
/// Compute the time spent on this task.
Compute the time spent on this task.
Compute the time spent on this task .
pub fn spent_time(&self) -> Duration {
    let (spent, last_wip) =
      self
        .history
        .iter()
        .fold((Duration::zero(), None), |(spent, last_wip), event| {
          match event {
            Event::StatusChanged { event_date, status } => match (status, last_wip) {
              // We go from any status to WIP status; return the spent time untouched and set the new “last_wip” with the
              // time at which the status change occurred
              (Status::Ongoing, _) => (spent, Some(event_date.clone())),
              // We go to anything but WIP while the previous status was WIP; accumulate.
              (_, Some(last_wip)) => (spent + (event_date.signed_duration_since(last_wip)), None),
              // We go between inactive status, ignore
              _ => (spent, last_wip),
            },
            _ => (spent, last_wip),
          }
        });
    if let Some(last_wip) = last_wip {
      // last status was WIP; accumulate moaaar
      spent + Utc::now().signed_duration_since(last_wip)
    } else {
      spent
    }
  }
pub fn spent_time ( & self ) -> Duration { let ( spent , last_wip ) = self . history . iter ( ) . fold ( ( Duration :: zero ( ) , None ) , | ( spent , last_wip ) , event | { match event { Event :: StatusChanged { event_date , status } => match ( status , last_wip ) { // We go from any status to WIP status; return the spent time untouched and set the new “last_wip” with the // time at which the status change occurred ( Status :: Ongoing , _ ) => ( spent , Some ( event_date . clone ( ) ) ) , // We go to anything but WIP while the previous status was WIP; accumulate. ( _ , Some ( last_wip ) ) => ( spent + ( event_date . signed_duration_since ( last_wip ) ) , None ) , // We go between inactive status, ignore _ => ( spent , last_wip ) , } , _ => ( spent , last_wip ) , } } ) ; if let Some ( last_wip ) = last_wip { // last status was WIP; accumulate moaaar spent + Utc :: now ( ) . signed_duration_since ( last_wip ) } else { spent } }
Compute the time spent on this task.
Compute the time spent on this task .
&self
&self