Skip to content

Commit 655c195

Browse files
Merge pull request #10155 from gitbutlerapp/fix-timezones
Fix timezones
2 parents b8b302e + 5ed5572 commit 655c195

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

apps/desktop/src/components/codegen/CodegenServiceMessage.svelte

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,16 @@
6868
return `${seconds.toFixed(1)}s`;
6969
}
7070
71-
function getUTCNow() {
72-
const time = new Date();
73-
const offset = time.getTimezoneOffset();
74-
return Date.now() + offset * 1000 * 60;
75-
}
76-
7771
let currentWord = $state(getWord());
78-
let currentDuration = $state(milisToEnglish(getUTCNow() - lastUserMessageSent.getTime()));
72+
let currentDuration = $state(milisToEnglish(Date.now() - lastUserMessageSent.getTime()));
7973
8074
$effect(() => {
8175
const updateWordInterval = setInterval(() => {
8276
currentWord = getWord();
8377
}, 1000 * 15);
8478
8579
const updateTimeInterval = setInterval(() => {
86-
currentDuration = milisToEnglish(getUTCNow() - lastUserMessageSent.getTime());
80+
currentDuration = milisToEnglish(Date.now() - lastUserMessageSent.getTime());
8781
}, 100);
8882
8983
return () => {

apps/desktop/src/lib/codegen/messages.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ export function currentStatus(events: ClaudeMessage[], isActive: boolean): Claud
281281
return 'running';
282282
}
283283

284+
function normalizeDate(date: Date): Date {
285+
return new Date(date.getTime() - date.getTimezoneOffset() * 60 * 1000);
286+
}
287+
284288
/**
285289
* Thinking duration in ms
286290
*/
@@ -293,7 +297,7 @@ export function lastUserMessageSentAt(events: ClaudeMessage[]): Date | undefined
293297
}
294298
}
295299
if (!event) return;
296-
return new Date(event.createdAt);
300+
return normalizeDate(new Date(event.createdAt));
297301
}
298302

299303
/**
@@ -302,7 +306,8 @@ export function lastUserMessageSentAt(events: ClaudeMessage[]): Date | undefined
302306
export function lastInteractionTime(events: ClaudeMessage[]): Date | undefined {
303307
if (events.length === 0) return undefined;
304308
const lastEvent = events[events.length - 1];
305-
return lastEvent ? new Date(lastEvent.createdAt) : undefined;
309+
if (!lastEvent) return;
310+
return normalizeDate(new Date(lastEvent.createdAt));
306311
}
307312

308313
/**

0 commit comments

Comments
 (0)