adasd
This commit is contained in:
@@ -1,6 +1,27 @@
|
||||
const payloadNode = document.getElementById('desktop-payload');
|
||||
|
||||
if (payloadNode) {
|
||||
const syncDesktopTimezone = () => {
|
||||
try {
|
||||
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone || 'Europe/Berlin';
|
||||
if (!timezone) {
|
||||
return;
|
||||
}
|
||||
|
||||
const encoded = encodeURIComponent(timezone);
|
||||
const currentCookie = document.cookie.split('; ').find((entry) => entry.startsWith('desktop_timezone='));
|
||||
if (currentCookie === `desktop_timezone=${encoded}`) {
|
||||
return;
|
||||
}
|
||||
|
||||
document.cookie = `desktop_timezone=${encoded}; path=/; max-age=31536000; samesite=lax`;
|
||||
} catch {
|
||||
// Ignore timezone detection failures.
|
||||
}
|
||||
};
|
||||
|
||||
syncDesktopTimezone();
|
||||
|
||||
const payload = JSON.parse(payloadNode.textContent);
|
||||
const desktopStage = document.querySelector('.desktop-stage');
|
||||
const iconsRoot = document.getElementById('desktop-icons');
|
||||
|
||||
@@ -418,9 +418,21 @@ namespace {
|
||||
if (!function_exists('nexus_display_timezone_name')) {
|
||||
function nexus_display_timezone_name(): string
|
||||
{
|
||||
$timezone = trim((string) date_default_timezone_get());
|
||||
$candidates = [
|
||||
$_COOKIE['desktop_timezone'] ?? null,
|
||||
$_SESSION['desktop_timezone'] ?? null,
|
||||
getenv('DESKTOP_TIMEZONE') ?: null,
|
||||
'Europe/Berlin',
|
||||
];
|
||||
|
||||
return $timezone !== '' ? $timezone : 'Europe/Berlin';
|
||||
foreach ($candidates as $candidate) {
|
||||
$timezone = trim((string) $candidate);
|
||||
if ($timezone !== '' && in_array($timezone, \DateTimeZone::listIdentifiers(), true)) {
|
||||
return $timezone;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Europe/Berlin';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user