Skip to content

Commit 65fbcbe

Browse files
fix: outlook notification showing event time in the wrong timezone (RocketChat#37318)
Co-authored-by: Pierre Lehnen <55164754+pierre-lehnen-rc@users.noreply.github.com>
1 parent 5c57e84 commit 65fbcbe

4 files changed

Lines changed: 26 additions & 1 deletion

File tree

.changeset/proud-dryers-jump.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@rocket.chat/meteor": minor
3+
"@rocket.chat/core-typings": minor
4+
---
5+
6+
Fixes the time display in calendar event notifications by converting the UTC time to the local time.
7+

apps/meteor/client/views/root/hooks/loggedIn/useNotificationUserCalendar.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,24 @@ export const useNotificationUserCalendar = (user: IUser) => {
1515
return;
1616
}
1717

18+
let body = notification.text;
19+
if (notification.payload?.startTimeUtc) {
20+
try {
21+
const time = new Date(notification.payload.startTimeUtc);
22+
const formattedTime = time.toLocaleTimeString(undefined, {
23+
hour: 'numeric',
24+
minute: 'numeric',
25+
dayPeriod: 'narrow',
26+
});
27+
body = formattedTime;
28+
} catch (error) {
29+
console.error('Failed to format calendar notification time:', error);
30+
body = notification.text;
31+
}
32+
}
33+
1834
const n = new Notification(notification.title, {
19-
body: notification.text,
35+
body,
2036
tag: notification.payload._id,
2137
silent: true,
2238
requireInteraction,

apps/meteor/server/services/calendar/service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ export class CalendarService extends ServiceClassInternal implements ICalendarSe
355355
text: event.startTime.toLocaleTimeString(undefined, { hour: 'numeric', minute: 'numeric', dayPeriod: 'narrow' }),
356356
payload: {
357357
_id: event._id,
358+
startTimeUtc: event.startTime.toISOString(),
358359
},
359360
});
360361
}

packages/core-typings/src/INotification.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,6 @@ export interface ICalendarNotification {
7575
text: string;
7676
payload: {
7777
_id: ICalendarEvent['_id'];
78+
startTimeUtc?: string;
7879
};
7980
}

0 commit comments

Comments
 (0)