Add the ability to edit the time on a time_distance record
This commit is contained in:
parent
4acf034b8d
commit
38b1e62b60
|
@ -25,7 +25,7 @@ use dimensioned::si;
|
||||||
use ft_core::{TimeDistance, TimeDistanceActivity};
|
use ft_core::{TimeDistance, TimeDistanceActivity};
|
||||||
use glib::Object;
|
use glib::Object;
|
||||||
use gtk::{prelude::*, subclass::prelude::*};
|
use gtk::{prelude::*, subclass::prelude::*};
|
||||||
use std::{rc::Rc, cell::RefCell};
|
use std::{cell::RefCell, rc::Rc};
|
||||||
|
|
||||||
pub fn time_distance_summary(
|
pub fn time_distance_summary(
|
||||||
distance: DistanceFormatter,
|
distance: DistanceFormatter,
|
||||||
|
@ -202,8 +202,20 @@ impl TimeDistanceEdit {
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_time(&self, _time: Option<TimeFormatter>) {
|
fn update_time(&self, time: Option<TimeFormatter>) {
|
||||||
unimplemented!()
|
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>) {
|
fn update_distance(&self, distance: Option<DistanceFormatter>) {
|
||||||
|
|
Loading…
Reference in New Issue