Add the ability to edit the time of a workout and the associated activity. #183
|
@ -25,7 +25,7 @@ use dimensioned::si;
|
|||
use ft_core::{TimeDistance, TimeDistanceActivity};
|
||||
use glib::Object;
|
||||
use gtk::{prelude::*, subclass::prelude::*};
|
||||
use std::{rc::Rc, cell::RefCell};
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
pub fn time_distance_summary(
|
||||
distance: DistanceFormatter,
|
||||
|
@ -202,8 +202,20 @@ impl TimeDistanceEdit {
|
|||
s
|
||||
}
|
||||
|
||||
fn update_time(&self, _time: Option<TimeFormatter>) {
|
||||
unimplemented!()
|
||||
fn update_time(&self, time: Option<TimeFormatter>) {
|
||||
if let Some(time_formatter) = time {
|
||||
let mut workout = self.imp().workout.borrow_mut();
|
||||
let tz = workout.datetime.timezone();
|
||||
let new_time = workout
|
||||
.datetime
|
||||
.date_naive()
|
||||
.and_time(*time_formatter)
|
||||
.and_local_timezone(tz)
|
||||
.unwrap()
|
||||
.fixed_offset();
|
||||
workout.datetime = new_time;
|
||||
(self.imp().on_update.borrow())(workout.clone());
|
||||
}
|
||||
}
|
||||
|
||||
fn update_distance(&self, distance: Option<DistanceFormatter>) {
|
||||
|
|
Loading…
Reference in New Issue