Skip to content

Commit

Permalink
[date] [date-range] Fix UTC time issue
Browse files Browse the repository at this point in the history
Signed-off-by: Xavier Marin <[email protected]>
  • Loading branch information
Giwi committed Dec 15, 2023
1 parent 148a4b0 commit f7b514f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/components/discovery-input/discovery-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export class DiscoveryInputComponent {
enableSeconds: true,
time_24hr: true,
plugins: [],
formatDate: (d: Date) => GTSLib.toISOString(d.valueOf() * divider, divider, this.innerOptions.timeZone,
formatDate: (d: Date) => GTSLib.toISOString(GTSLib.zonedTimeToUtc(d.valueOf(), 1) * divider, divider, this.innerOptions.timeZone,
this.innerOptions.fullDateDisplay ? this.innerOptions.timeFormat : undefined)
} as any;
if (this.subType === 'date-range') {
Expand All @@ -185,11 +185,9 @@ export class DiscoveryInputComponent {
this.flatpickrInstance = flatpickr(this.inputField as HTMLInputElement, opts);
this.flatpickrInstance.config.onChange.push((d: any[], s: string) => {
if (this.subType === 'date-range') {
this.selectedValue = d
.map(date => date.toISOString())
.map(date => GTSLib.toTimestamp(date, divider, this.innerOptions.timeZone));
this.selectedValue = d.map(date => GTSLib.zonedTimeToUtc(date.valueOf(), 1) * divider);
} else {
this.selectedValue = GTSLib.toTimestamp(s, divider, this.innerOptions.timeZone);
this.selectedValue = GTSLib.zonedTimeToUtc(GTSLib.toTimestamp(s, divider, this.innerOptions.timeZone), 1);
}
if (!this.innerOptions.input?.showButton) {
this.handleClick();
Expand Down

0 comments on commit f7b514f

Please sign in to comment.