From c4a7af7b0525b860b4096a09065fb8c9c3b907f5 Mon Sep 17 00:00:00 2001 From: tugcekucukoglu Date: Mon, 11 Dec 2023 13:20:45 +0300 Subject: [PATCH] Fixed #4952 - Calendar: Time only mode does not work --- components/lib/calendar/Calendar.vue | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/components/lib/calendar/Calendar.vue b/components/lib/calendar/Calendar.vue index e444ccd22..40e478f4b 100755 --- a/components/lib/calendar/Calendar.vue +++ b/components/lib/calendar/Calendar.vue @@ -1272,10 +1272,14 @@ export default { let formattedValue = null; if (date) { - formattedValue = this.formatDate(date, this.datePattern); + if (this.timeOnly) { + formattedValue = this.formatTime(date); + } else { + formattedValue = this.formatDate(date, this.datePattern); - if (this.showTime || this.timeOnly) { - formattedValue += ' ' + this.formatTime(date); + if (this.showTime) { + formattedValue += ' ' + this.formatTime(date); + } } } @@ -1798,13 +1802,18 @@ export default { let date; let parts = text.split(' '); - const dateFormat = this.datePattern; - - if (this.showTime || this.timeOnly) { - date = this.parseDate(parts[0], dateFormat); - this.populateTime(date, parts[1], parts[2]); + if (this.timeOnly) { + date = new Date(this.modelValue); + this.populateTime(date, parts[0], parts[1]); } else { - date = this.parseDate(text, dateFormat); + const dateFormat = this.datePattern; + + if (this.showTime) { + date = this.parseDate(parts[0], dateFormat); + this.populateTime(date, parts[1], parts[2]); + } else { + date = this.parseDate(text, dateFormat); + } } return date;