Make sure component always returns midnight utc.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@tp/tp-date-picker",
|
"name": "@tp/tp-date-picker",
|
||||||
"version": "3.0.1",
|
"version": "3.0.2",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "tp-date-picker.js",
|
"main": "tp-date-picker.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -290,15 +290,9 @@ class TpDatePicker extends FormElement(LitElement) {
|
|||||||
for (const el of e.composedPath()) {
|
for (const el of e.composedPath()) {
|
||||||
if (el.date !== undefined) {
|
if (el.date !== undefined) {
|
||||||
this.value = el.date;
|
this.value = el.date;
|
||||||
// Interpret the selected date as being in the user's timezone, output as UTC ISO string
|
|
||||||
const selectedDate = el.date;
|
const selectedDate = el.date;
|
||||||
let outputValue;
|
// Date-only fields always store UTC midnight — the calendar date is timezone-agnostic.
|
||||||
const zone = this.timeZone || 'local';
|
const outputValue = DateTime.utc(selectedDate.year, selectedDate.month, selectedDate.day).toISO();
|
||||||
const localDate = DateTime.fromObject(
|
|
||||||
{ year: selectedDate.year, month: selectedDate.month, day: selectedDate.day },
|
|
||||||
{ zone }
|
|
||||||
);
|
|
||||||
outputValue = localDate.toUTC().toISO();
|
|
||||||
this.dispatchEvent(new CustomEvent('value-changed', { detail: outputValue, bubbles: true, composed: true }));
|
this.dispatchEvent(new CustomEvent('value-changed', { detail: outputValue, bubbles: true, composed: true }));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user