Skip to content

Commit f6fb28c

Browse files
committed
Adjust 'Starts/Ends in ...' for user time zone
1 parent d2d4c93 commit f6fb28c

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/ui.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,15 @@ export async function buildSockView(
4949

5050
const latestWakaData = await getLatestWakaData(slackId);
5151

52+
const adjustedNowTimestamp = Date.now() + (tz_offset ?? 0) * 1000;
53+
const adjustedStartTimestamp =
54+
eventStartDate.getTime() + (tz_offset ?? 0) * 1000;
55+
const adjustedEndTimestamp = eventEndDate.getTime() + (tz_offset ?? 0) * 1000;
56+
5257
let rn =
53-
Date.now() < eventStartDate.getTime()
54-
? eventStartDate.getTime() - Date.now()
55-
: eventEndDate.getTime() - Date.now();
58+
adjustedNowTimestamp < adjustedStartTimestamp
59+
? adjustedStartTimestamp - adjustedNowTimestamp
60+
: adjustedEndTimestamp - adjustedNowTimestamp;
5661

5762
let days = Math.floor(rn / (86400 * 1000));
5863
rn -= days * (86400 * 1000);

0 commit comments

Comments
 (0)