From 6f053d849a17f21dcd67105870f9da984fcee225 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Sun, 4 Apr 2021 21:38:27 +0200 Subject: [PATCH] [utils] IsoDateTime, do not set time if used as date input --- src/components/utils/IsoDateInput.vue | 2 +- src/utils/datetime.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/utils/IsoDateInput.vue b/src/components/utils/IsoDateInput.vue index 2e83d55..6d7460b 100644 --- a/src/components/utils/IsoDateInput.vue +++ b/src/components/utils/IsoDateInput.vue @@ -127,7 +127,7 @@ export default defineComponent({ } function modifyDate(v: string, d: Date | undefined = props.modelValue) { - if (!d) d = new Date(); + if (!d) d = q_date.buildDate({ hours: 0, minutes: 0, seconds: 0 }); if (/^\d{4}-\d\d-\d\d$/.test(v)) { const split = v.split('-'); return q_date.adjustDate(d, { diff --git a/src/utils/datetime.ts b/src/utils/datetime.ts index 3fc0139..0a3bd72 100644 --- a/src/utils/datetime.ts +++ b/src/utils/datetime.ts @@ -17,8 +17,12 @@ export function formatDateTime( return dateTimeFormat.format(date); } +export function asDate(date?: Date) { + return date ? formatDateTime(date, true) : ''; +} + export function asHour(date?: Date) { - if (date) return formatDateTime(date, false, true); + return date ? formatDateTime(date, false, true) : ''; } export function startOfWeek(date: Date, startMonday = true) {