Add the ability to edit the time of a workout and the associated activity. #183

Merged
savanni merged 5 commits from fitnesstrax/edit-time-and-activity into main 2024-02-09 13:31:40 +00:00
1 changed files with 15 additions and 3 deletions
Showing only changes of commit 38b1e62b60 - Show all commits

View File

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