Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/proud-dryers-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@rocket.chat/meteor": minor
"@rocket.chat/core-typings": minor
---

Fixes the time display in calendar event notifications by converting the UTC time to the local time.

Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,24 @@ export const useNotificationUserCalendar = (user: IUser) => {
return;
}

let body = notification.text;
if (notification.payload?.startTimeUtc) {
try {
const time = new Date(notification.payload.startTimeUtc);
const formattedTime = time.toLocaleTimeString(undefined, {
hour: 'numeric',
minute: 'numeric',
dayPeriod: 'narrow',
});
body = formattedTime;
} catch (error) {
console.error('Failed to format calendar notification time:', error);
body = notification.text;
}
}

const n = new Notification(notification.title, {
body: notification.text,
body,
tag: notification.payload._id,
silent: true,
requireInteraction,
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/server/services/calendar/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ export class CalendarService extends ServiceClassInternal implements ICalendarSe
text: event.startTime.toLocaleTimeString(undefined, { hour: 'numeric', minute: 'numeric', dayPeriod: 'narrow' }),
payload: {
_id: event._id,
startTimeUtc: event.startTime.toISOString(),
},
});
}
Expand Down
1 change: 1 addition & 0 deletions packages/core-typings/src/INotification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,6 @@ export interface ICalendarNotification {
text: string;
payload: {
_id: ICalendarEvent['_id'];
startTimeUtc?: string;
};
}
Loading