feat: Add timezone support with EST default
- Add TIMEZONE config option (default: America/New_York) - Set PHP default timezone from config - Add timezone offset and abbreviation for JavaScript - Update stat card filters to use server timezone - Add timezone config to Dashboard and Ticket views Timezone can be changed via TIMEZONE env variable. All dates now consistent with server timezone (EST by default). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,10 @@
|
||||
require_once __DIR__ . '/../middleware/CsrfMiddleware.php';
|
||||
echo CsrfMiddleware::getToken();
|
||||
?>';
|
||||
// Timezone configuration (from server)
|
||||
window.APP_TIMEZONE = '<?php echo $GLOBALS['config']['TIMEZONE']; ?>';
|
||||
window.APP_TIMEZONE_OFFSET = <?php echo $GLOBALS['config']['TIMEZONE_OFFSET']; ?>; // minutes from UTC
|
||||
window.APP_TIMEZONE_ABBREV = '<?php echo $GLOBALS['config']['TIMEZONE_ABBREV']; ?>';
|
||||
</script>
|
||||
</head>
|
||||
<body data-categories='<?php echo json_encode($categories); ?>' data-types='<?php echo json_encode($types); ?>'>
|
||||
@@ -693,13 +697,25 @@
|
||||
}
|
||||
});
|
||||
|
||||
// Helper function to get date in server timezone
|
||||
function getServerDate() {
|
||||
// Get current UTC time
|
||||
const now = new Date();
|
||||
// Apply server timezone offset (APP_TIMEZONE_OFFSET is in minutes)
|
||||
const serverTime = new Date(now.getTime() + (window.APP_TIMEZONE_OFFSET * 60000) + (now.getTimezoneOffset() * 60000));
|
||||
return serverTime.getFullYear() + '-' +
|
||||
String(serverTime.getMonth() + 1).padStart(2, '0') + '-' +
|
||||
String(serverTime.getDate()).padStart(2, '0');
|
||||
}
|
||||
|
||||
// Stat card click handlers for filtering
|
||||
document.querySelectorAll('.stat-card').forEach(card => {
|
||||
card.style.cursor = 'pointer';
|
||||
card.addEventListener('click', function() {
|
||||
const classList = this.classList;
|
||||
let url = '/?';
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
// Use server timezone date (default: EST)
|
||||
const today = getServerDate();
|
||||
|
||||
if (classList.contains('stat-open')) {
|
||||
url += 'status=Open';
|
||||
|
||||
Reference in New Issue
Block a user