Skip to content

Commit

Permalink
Round end time to full 15m (#111)
Browse files Browse the repository at this point in the history
For part-time workers, the end time will be odd, e.g., for 36h/week the end time will default to 17:12. As we are supposed to book to the nearest 15 minutes, the end time should be rounded up/down. Otherwise, the +/- buttons are not usable without manual adjustments.
  • Loading branch information
kiwikern authored Nov 4, 2024
1 parent 43abc78 commit c91e0ea
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/routes/work_time.($id).tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ const DEFAULT_BREAK_TIME = 60;
function getEndTime(workTime: number) {
// calculate end time based on daily work time from personio
const momentStartTime = moment(DEFAULT_START_TIME, "HH:mm");
const momentWorkTime = moment(minutesToTime(workTime * 60), "HH:mm");
// e.g. 36h work week results in 7:12 hours -> round up/down to full fifteen minutes
const workTimeMinutes = Math.round((workTime * 60) / 15) * 15;
const momentWorkTime = moment(minutesToTime(workTimeMinutes), "HH:mm");

return momentStartTime
.add(DEFAULT_BREAK_TIME, "minutes")
Expand Down

0 comments on commit c91e0ea

Please sign in to comment.