Merge pull request #1612 from alxlab-zone66x/feature/1611

#1611 Breaks bug when Time Format is set to regular
This commit is contained in:
Alex Tselegidis 2024-11-05 13:21:15 +01:00 committed by GitHub
commit 47220130f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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(),
);
}