Add the ability to edit the time on a time_distance record

This commit is contained in:
Savanni D'Gerinel 2024-02-08 21:58:22 -05:00
parent 4acf034b8d
commit 38b1e62b60
1 changed files with 15 additions and 3 deletions

View File

@ -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>) {