Compare commits
2 Commits
1df7db4303
...
093ab1372d
| Author | SHA1 | Date | |
|---|---|---|---|
| 093ab1372d | |||
| c66db8cd86 |
+1
-1
@@ -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
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user