Create new records with the date of the view model

This commit is contained in:
Savanni D'Gerinel 2024-02-08 22:11:46 -05:00
parent 38b1e62b60
commit 6394d89331
1 changed files with 12 additions and 1 deletions

View File

@ -176,9 +176,20 @@ impl DayDetailViewModel {
} }
pub fn new_time_distance(&self, activity: TimeDistanceActivity) -> Record<TimeDistance> { pub fn new_time_distance(&self, activity: TimeDistanceActivity) -> Record<TimeDistance> {
let now = chrono::Local::now();
let base_time = now.time();
let tz = now.timezone();
let datetime = self
.date
.clone()
.and_time(base_time)
.and_local_timezone(tz)
.unwrap()
.into();
let id = RecordId::default(); let id = RecordId::default();
let workout = TimeDistance { let workout = TimeDistance {
datetime: chrono::Local::now().into(), datetime,
activity, activity,
distance: None, distance: None,
duration: None, duration: None,