From e4e262595a234bc9df51163ebd49267db88d8f1b Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Tue, 17 Mar 2026 13:23:16 +0000 Subject: [PATCH] adding timezone --- index.php | 34 ++++++++++++++++++++++++++++++++++ repair_timezone.py | 10 ++++++++++ 2 files changed, 44 insertions(+) create mode 100644 repair_timezone.py diff --git a/index.php b/index.php index c723646..a50dd78 100644 --- a/index.php +++ b/index.php @@ -49,6 +49,27 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { file_put_contents('post_debug.log', date('Y-m-d H:i:s') . " - POST: " . json_encode($_POST) . "\n", FILE_APPEND); } require_once 'db/config.php'; + +# Timezone setup +try { + $stmt_tz = db()->prepare("SELECT `value` FROM settings WHERE `key` = 'time_zone'"); + $stmt_tz->execute(); + $tz_setting = $stmt_tz->fetchColumn(); + $timezone = $tz_setting ?: 'Asia/Muscat'; // Default to Muscat + date_default_timezone_set($timezone); + # Sync DB + $now = new DateTime(); + $mins = $now->getOffset() / 60; + $sgn = ($mins < 0 ? -1 : 1); + $mins = abs($mins); + $hrs = floor($mins / 60); + $mins -= $hrs * 60; + $offset = sprintf('%+d:%02d', $hrs * $sgn, $mins); + db()->exec("SET time_zone = '$offset'"); +} catch (Exception $e) { + date_default_timezone_set('Asia/Muscat'); +} + require_once 'includes/DatabaseInstaller.php'; // Auto-install database if not installed @@ -9031,6 +9052,19 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System'; +
+ + +
diff --git a/repair_timezone.py b/repair_timezone.py new file mode 100644 index 0000000..0375e81 --- /dev/null +++ b/repair_timezone.py @@ -0,0 +1,10 @@ +import os + +file_path = 'index.php' + +with open(file_path, 'r', encoding='utf-8') as f: + content = f.read() + +# Fix the syntax error +search_bad = 'echo "";' +replace_good = 'echo "