Skip to content

Commit 8b756e2

Browse files
committed
fix: use local time instead of JST
1 parent f753ccd commit 8b756e2

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

data-loader.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ mock.module("node:os", () => ({
2626
}));
2727

2828
describe("formatDate", () => {
29-
test("formats UTC timestamp to JST date", () => {
30-
// UTC midnight = JST 9 AM
29+
test("formats UTC timestamp to local date", () => {
30+
// Test with UTC timestamps - results depend on local timezone
3131
expect(formatDate("2024-01-01T00:00:00Z")).toBe("2024-01-01");
32-
// UTC 3 PM = JST midnight next day
33-
expect(formatDate("2024-01-01T15:00:00Z")).toBe("2024-01-02");
32+
expect(formatDate("2024-01-01T15:00:00Z")).toBe("2024-01-01");
3433
});
3534

3635
test("handles various date formats", () => {

data-loader.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ export type SessionUsage = v.InferOutput<typeof SessionUsageSchema>;
3939

4040
export const formatDate = (dateStr: string): string => {
4141
const date = new Date(dateStr);
42-
const offsetDate = new Date(date.getTime() + 9 * 60 * 60 * 1000); // UTC+9 for JST
43-
const year = offsetDate.getUTCFullYear();
44-
const month = String(offsetDate.getUTCMonth() + 1).padStart(2, "0");
45-
const day = String(offsetDate.getUTCDate()).padStart(2, "0");
42+
const year = date.getFullYear();
43+
const month = String(date.getMonth() + 1).padStart(2, "0");
44+
const day = String(date.getDate()).padStart(2, "0");
4645
return `${year}-${month}-${day}`;
4746
};
4847

0 commit comments

Comments
 (0)