From e7140448546c944bcabc76b809abc8475a720f26 Mon Sep 17 00:00:00 2001 From: pk Date: Fri, 10 Apr 2026 09:53:39 +0200 Subject: [PATCH] Make sure component always returns midnight utc. --- package.json | 2 +- tp-date-picker.js | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 40f2a67..528ac88 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tp/tp-date-picker", - "version": "3.0.1", + "version": "3.0.2", "description": "", "main": "tp-date-picker.js", "scripts": { diff --git a/tp-date-picker.js b/tp-date-picker.js index 695959b..c4b115a 100644 --- a/tp-date-picker.js +++ b/tp-date-picker.js @@ -290,15 +290,9 @@ class TpDatePicker extends FormElement(LitElement) { for (const el of e.composedPath()) { if (el.date !== undefined) { this.value = el.date; - // Interpret the selected date as being in the user's timezone, output as UTC ISO string const selectedDate = el.date; - let outputValue; - const zone = this.timeZone || 'local'; - const localDate = DateTime.fromObject( - { year: selectedDate.year, month: selectedDate.month, day: selectedDate.day }, - { zone } - ); - outputValue = localDate.toUTC().toISO(); + // Date-only fields always store UTC midnight — the calendar date is timezone-agnostic. + const outputValue = DateTime.utc(selectedDate.year, selectedDate.month, selectedDate.day).toISO(); this.dispatchEvent(new CustomEvent('value-changed', { detail: outputValue, bubbles: true, composed: true })); return; }