Skip to content

Hotfix workout time backfill and edit timezone parsing#45

Merged
brianwalborn merged 1 commit intomainfrom
feature/workout-time-hotfix
Mar 25, 2026
Merged

Hotfix workout time backfill and edit timezone parsing#45
brianwalborn merged 1 commit intomainfrom
feature/workout-time-hotfix

Conversation

@brianwalborn
Copy link
Copy Markdown
Owner

This pull request addresses and corrects the logic for handling workout start and end times throughout the backend and frontend, ensuring consistency in how these times are calculated, stored, and displayed. The main focus is on fixing previous errors in time backfilling during migrations, improving workout creation and update logic, and ensuring date parsing is robust on the frontend.

Backend data correction and logic fixes:

  • Database migration fix for workout times:
    Added a new Alembic migration (2b3c4d5e6f7a_fix_workout_time_backfill.py) to correct previously backfilled start_time and end_time values in the workouts table. This migration ensures that start_time is set to date - duration and end_time is set to date, fixing earlier logic that had these reversed.

  • Fix workout creation and update logic:
    Updated create_workout and update_workout in backend/app/crud/workouts.py to consistently treat date as the workout end time, and to always compute start_time as end_time - duration when not explicitly provided. Also, the date field is now set to match end_time for new and updated workouts. [1] [2]

  • Corrected original migration logic:
    Modified the original migration (1a2b3c4d5e6f_add_start_end_times_to_workouts.py) so that start_time is calculated as end_time - duration and end_time is set to the value of date, aligning with the corrected definition.

Frontend date handling improvements:

  • Robust date parsing and time calculation:
    Introduced the parseWorkoutDateTime utility in ProgressView.vue to properly handle ISO date strings (with or without timezone info), preventing timezone-related bugs when displaying or editing workout times. Updated all relevant usages to utilize this function. [1] [2]

@brianwalborn brianwalborn merged commit bb822e0 into main Mar 25, 2026
@brianwalborn brianwalborn deleted the feature/workout-time-hotfix branch March 25, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant