Compare commits

...

2 Commits

Author SHA1 Message Date
pk 093ab1372d Bump version 2026-04-07 11:01:38 +02:00
pk c66db8cd86 Returned date should always in UTC. Timezone is only for display. 2026-04-07 11:01:25 +02:00
2 changed files with 12 additions and 2 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@tp/tp-date-picker",
"version": "3.0.0",
"version": "3.0.1",
"description": "",
"main": "tp-date-picker.js",
"scripts": {
+11 -1
View File
@@ -220,6 +220,7 @@ class TpDatePicker extends FormElement(LitElement) {
yearsBackwards: { type: Number },
showYearSelector: { type: Boolean },
events: { type: Array },
timeZone: { type: String }, // User's timezone for date interpretation
};
}
@@ -289,7 +290,16 @@ class TpDatePicker extends FormElement(LitElement) {
for (const el of e.composedPath()) {
if (el.date !== undefined) {
this.value = el.date;
this.dispatchEvent(new CustomEvent('value-changed', { detail: this.value, bubbles: true, composed: true }));
// 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();
this.dispatchEvent(new CustomEvent('value-changed', { detail: outputValue, bubbles: true, composed: true }));
return;
}
}