timerender: Move display_time_zone fallback to initialize.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-12-03 15:38:24 -08:00 committed by Tim Abbott
parent 8a1630ee42
commit ec44722252
2 changed files with 13 additions and 12 deletions

View File

@ -19,17 +19,6 @@ import {user_settings} from "./user_settings";
let next_timerender_id = 0;
export let display_time_zone = new Intl.DateTimeFormat().resolvedOptions().timeZone;
if (
display_time_zone === undefined || // https://bugs.chromium.org/p/chromium/issues/detail?id=1487920
display_time_zone === "Etc/Unknown" // https://bugs.chromium.org/p/chromium/issues/detail?id=1473422
) {
display_time_zone = user_settings.timezone;
try {
new Intl.DateTimeFormat(undefined, {timeZone: display_time_zone});
} catch {
display_time_zone = "UTC";
}
}
const formatter_map = new Map<string, Intl.DateTimeFormat>();
@ -341,6 +330,18 @@ let update_list: UpdateEntry[] = [];
let last_update: Date;
export function initialize(): void {
if (
display_time_zone === undefined || // https://bugs.chromium.org/p/chromium/issues/detail?id=1487920
display_time_zone === "Etc/Unknown" // https://bugs.chromium.org/p/chromium/issues/detail?id=1473422
) {
display_time_zone = user_settings.timezone;
try {
new Intl.DateTimeFormat(undefined, {timeZone: display_time_zone});
} catch {
display_time_zone = "UTC";
}
}
last_update = start_of_day(new Date(), display_time_zone);
}

View File

@ -494,6 +494,7 @@ export function initialize_everything() {
}
i18n.initialize(i18n_params);
timerender.initialize();
widgets.initialize();
tippyjs.initialize();
compose_tooltips.initialize();
@ -609,7 +610,6 @@ export function initialize_everything() {
copy_and_paste.initialize();
overlays.initialize();
invite.initialize();
timerender.initialize();
message_view_header.initialize();
server_events.initialize();
user_status.initialize(user_status_params);