Skip to content

Commit 30a36a0

Browse files
authored
Update mgt-agenda.ts (#746)
Fixed `prettyPrintTimeFromDateTime` to not do a UTC->Browser shift on times when a preferred time zone is specified.
1 parent 429094b commit 30a36a0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/mgt/src/components/mgt-agenda/mgt-agenda.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,15 @@ export class MgtAgenda extends MgtTemplatedComponent {
577577
}
578578

579579
private prettyPrintTimeFromDateTime(date: Date) {
580-
date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
580+
// If a preferred time zone was sent in the Graph request
581+
// times are already set correctly. Do not adjust
582+
if (!this.preferredTimezone) {
583+
// If no preferred time zone was specified, the times are in UTC
584+
// fall back to old behavior and adjust the times to the browser's
585+
// time zone
586+
date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
587+
}
588+
581589
let hours = date.getHours();
582590
const minutes = date.getMinutes();
583591
const ampm = hours >= 12 ? 'PM' : 'AM';

0 commit comments

Comments
 (0)