Skip to content

Commit 7753f11

Browse files
javier-godoypaodb
authored andcommitted
fix: fix timezone handling in inline-date-picker
Close #59
1 parent bc84ab0 commit 7753f11

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/resources/META-INF/frontend/fc-inline-date-picker/fc-inline-date-picker.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* #L%
1919
*/
2020
import { css, html, LitElement } from 'lit';
21+
import {formatDate} from '../fc-year-calendar/fc-calendar-utils.js';
2122

2223
export class InlineDatePicker extends LitElement {
2324

@@ -41,13 +42,13 @@ export class InlineDatePicker extends LitElement {
4142
willUpdate(changedProperties) {
4243
if (changedProperties.has('value')) {
4344
this.date = this.value ? new Date(this.value) : undefined;
44-
if(this.date){
45+
if(this.date && this.date.getTimezoneOffset()>0){
4546
// normalize date ignoring browser timezone
4647
this.date = new Date(this.date.toISOString().slice(0, -1));
4748
}
4849
}
4950
if (changedProperties.has('date')) {
50-
this.value = this.date ? this.date.toISOString().substring(0,10) : undefined;
51+
this.value = this.date ? formatDate(this.date).substring(0,10) : undefined;
5152
this.displayDate = this.date || this.displayDate;
5253
}
5354
if (changedProperties.has('displayDate')) {

0 commit comments

Comments
 (0)