Skip to content

Commit 2137248

Browse files
authored
fix: send timestamp in utc (#967)
* fix: send timestamp in utc * fix: address comment
1 parent ac8cc6e commit 2137248

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

frontend/lib/time.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { differenceInHours, format, parseISO } from "date-fns";
1+
import { differenceInHours, parseISO } from "date-fns";
22
import { z } from "zod/v4";
33

44
import { GroupByInterval } from "@/lib/clickhouse/modifiers";
@@ -77,16 +77,19 @@ export const convertToTimeParameters = (input: TimeInput, groupByInterval?: Grou
7777
const interval = groupByInterval || inferGroupByInterval(start, end);
7878

7979
return TimeParametersSchema.parse({
80-
start_time: format(start, "yyyy-MM-dd HH:mm:ss.SSS"),
81-
end_time: format(end, "yyyy-MM-dd HH:mm:ss.SSS"),
80+
start_time: start.toISOString().replace("T", " ").replace("Z", ""),
81+
end_time: end.toISOString().replace("T", " ").replace("Z", ""),
8282
interval_unit: interval.toUpperCase(),
8383
});
8484
}
8585

8686
if (validatedInput.pastHours === "all") {
87+
const startISO = EARLIEST_DATE.toISOString();
88+
const endISO = new Date().toISOString();
89+
8790
return TimeParametersSchema.parse({
88-
start_time: format(EARLIEST_DATE, "yyyy-MM-dd HH:mm:ss.SSS"),
89-
end_time: format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS"),
91+
start_time: startISO.replace("T", " ").replace("Z", ""),
92+
end_time: endISO.replace("T", " ").replace("Z", ""),
9093
interval_unit: groupByInterval?.toUpperCase() || GroupByInterval.Day.toUpperCase(),
9194
});
9295
}
@@ -100,8 +103,8 @@ export const convertToTimeParameters = (input: TimeInput, groupByInterval?: Grou
100103
const interval = groupByInterval || inferGroupByInterval(start, now);
101104

102105
return TimeParametersSchema.parse({
103-
start_time: format(start, "yyyy-MM-dd HH:mm:ss.SSS"),
104-
end_time: format(now, "yyyy-MM-dd HH:mm:ss.SSS"),
106+
start_time: start.toISOString().replace("T", " ").replace("Z", ""),
107+
end_time: now.toISOString().replace("T", " ").replace("Z", ""),
105108
interval_unit: interval.toUpperCase(),
106109
});
107110
};

0 commit comments

Comments
 (0)