<?php
// Since I can't easily require Common.php without bootstrap, I'll copy the logic here for testing.
function get_egypt_time_test() {
    $timezone = new \DateTimeZone("Africa/Cairo");
    $dateTime = new \DateTime("now", $timezone);
    
    $year = (int)$dateTime->format('Y');
    $startDST = new \DateTime("last friday of April $year", $timezone);
    $endDST = new \DateTime("last thursday of October $year", $timezone);
    $endDST->setTime(23, 59, 59);

    $currentOffset = $timezone->getOffset($dateTime);
    
    $modified = false;
    if ($dateTime >= $startDST && $dateTime <= $endDST) {
        if ($currentOffset == 7200) {
            $dateTime->modify('+1 hour');
            $modified = true;
        }
    }
    
    return [$dateTime, $currentOffset, $modified];
}

date_default_timezone_set("Africa/Cairo");

list($egyptTime, $offset, $modified) = get_egypt_time_test();

echo "<h1>Time Check</h1>";
echo "System date(): " . date('Y-m-d H:i:s') . "<br>";
echo "PHP date_default_timezone_get(): " . date_default_timezone_get() . "<br>";
echo "Current Offset (Seconds): " . $offset . " (" . ($offset/3600) . " hours)<br>";
echo "Was Modified by Helper: " . ($modified ? "YES" : "NO") . "<br>";
echo "get_egypt_time() Result: " . $egyptTime->format('Y-m-d H:i:s') . "<br>";
echo "UTC time(): " . time() . " (" . gmdate('Y-m-d H:i:s', time()) . " UTC)<br>";
?>
