Make sure component always returns midnight utc.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@tp/tp-date-picker",
|
||||
"version": "3.0.1",
|
||||
"version": "3.0.2",
|
||||
"description": "",
|
||||
"main": "tp-date-picker.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user