Skip to content

Commit 6df94dc

Browse files
kennetha17ifox
authored andcommitted
Fix format supplied by backend for timepicker only and validate 24 times
1 parent 6d02239 commit 6df94dc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

frontend/js/components/DatePicker.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
wrap: true,
133133
altInput: true,
134134
altFormat: self.altFormatComputed,
135-
dateFormat: self.enableTime ? 'Z' : 'Y-m-d', // This is the universal format that will be parsed by the back-end.
135+
dateFormat: (self.enableTime && self.noCalendar) ? 'H:i:S' : (self.enableTime ? 'Z' : 'Y-m-d'), // This is the universal format that will be parsed by the back-end.
136136
static: self.staticMode,
137137
appendTo: self.staticMode ? self.$refs[self.refs.flatPicker] : undefined,
138138
enableTime: self.enableTime,
@@ -217,7 +217,8 @@
217217
},
218218
isValidTime: function (string) {
219219
const timeRegex = /^(0?[1-9]|1[0-2]):[0-5][0-9](?: (AM|PM))?$/i;
220-
return timeRegex.test(string);
220+
const time24HrRegex = /^([01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?$/;
221+
return timeRegex.test(string) || time24HrRegex.test(string);
221222
}
222223
},
223224
mounted: function () {

0 commit comments

Comments
 (0)