Thanks to xet7 !

Fixes #5782
This commit is contained in:
Lauri Ojansivu 2025-05-25 00:22:47 +03:00
parent 1979b1692d
commit aaa5f9885d
3 changed files with 7 additions and 23 deletions

View file

@ -83,8 +83,7 @@ export class DatePicker extends BlazeComponent {
{
'keyup .js-date-field'() {
// parse for localized date format in strict mode
const normalizedValue = Utils.normalizeDigits(this.find('#date').value);
const dateMoment = moment(normalizedValue, 'L', true);
const dateMoment = moment(this.find('#date').value, 'L', true);
if (dateMoment.isValid()) {
this.error.set('');
this.$('.js-datepicker').datepicker('update', dateMoment.toDate());
@ -92,10 +91,9 @@ export class DatePicker extends BlazeComponent {
},
'keyup .js-time-field'() {
// parse for localized time format in strict mode
const normalizedValue = Utils.normalizeDigits(this.find('#time').value);
const dateMoment = moment(
normalizedValue,
adjustedTimeFormat(),
this.find('#time').value,
adjustedTimeFormat(),
true,
);
if (dateMoment.isValid()) {
@ -106,14 +104,12 @@ export class DatePicker extends BlazeComponent {
evt.preventDefault();
// if no time was given, init with 12:00
const timeValue = Utils.normalizeDigits(evt.target.time.value);
const time =
timeValue ||
moment(new Date().setHours(12, 0, 0)).format('LT');
evt.target.time.value ||
moment(new Date().setHours(12, 0, 0)).format('LT');
const newTime = moment(time, adjustedTimeFormat(), true);
const dateValue = Utils.normalizeDigits(evt.target.date.value);
const newDate = moment(dateValue, 'L', true);
const dateString = `${dateValue} ${time}`;
const newDate = moment(evt.target.date.value, 'L', true);
const dateString = `${evt.target.date.value} ${time}`;
const newCompleteDate = moment(
dateString,
`L ${adjustedTimeFormat()}`,