diff --git a/package.json b/package.json index 76c54bc..d83c2b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tp/tp-date-input", - "version": "2.0.2", + "version": "2.0.3", "description": "", "main": "tp-date-input.js", "scripts": { diff --git a/tp-date-input.js b/tp-date-input.js index 3547a47..894a9cb 100644 --- a/tp-date-input.js +++ b/tp-date-input.js @@ -308,10 +308,18 @@ class TpDateInput extends EventHelpers(ControlState(FormElement(LitElement))) { this.inputs[1].invalid = false; this.inputs[2].invalid = false; - // Convert to specified timezone or use system timezone - const finalDt = this.timeZone ? dt.setZone(this.timeZone) : dt; + // If timeZone is specified, interpret the entered date values as being in that timezone + // and output as UTC. This ensures filters work correctly against UTC-stored dates. + let finalDt; + if (this.timeZone) { + // keepLocalTime: true interprets the entered values as being in the specified timezone + finalDt = this.timeZone ? dt.setZone(this.timeZone, { keepLocalTime: true }) : dt; + } else { + finalDt = dt; + } + this.date = finalDt.toJSDate(); - this.value = finalDt.toISO(); + this.value = finalDt.toUTC().toISO(); this.invalid = false; this.dispatchEvent(new CustomEvent('value-changed', { detail: this.value, bubbles: true, composed: true })); } else {