Skip to content

Commit

Permalink
Merge pull request #1612 from alxlab-zone66x/feature/1611
Browse files Browse the repository at this point in the history
#1611 Breaks bug when Time Format is set to regular
  • Loading branch information
alextselegidis authored Nov 5, 2024
2 parents 7145fd6 + 71a7b7f commit 4722013
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions assets/js/utils/working_plan.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,20 +529,21 @@ App.Utils.WorkingPlan = (function () {
* @param {jQuery.Event} event
*/
$(document).on('click', '.save-break', (event) => {
const timeFormat = vars('time_format') === 'regular' ? 'h:mm a' : 'HH:mm';
// Break's start time must always be prior to break's end.
const element = event.target;

const $modifiedRow = $(element).closest('tr');

const startMoment = moment($modifiedRow.find('.break-start input').val(), 'HH:mm');
const startMoment = moment($modifiedRow.find('.break-start input').val(), timeFormat);

const endMoment = moment($modifiedRow.find('.break-end input').val(), 'HH:mm');
const endMoment = moment($modifiedRow.find('.break-end input').val(), timeFormat);

if (startMoment.isAfter(endMoment)) {
$modifiedRow.find('.break-end input').val(
startMoment
.add(1, 'hour')
.format(vars('time_format') === 'regular' ? 'h:mm a' : 'HH:mm')
.format(timeFormat)
.toLowerCase(),
);
}
Expand Down

0 comments on commit 4722013

Please sign in to comment.