<?php

namespace App\Support;

use DateTimeImmutable;
use DateTimeZone;

/**
 * Single calendar/clock source for Dashboard, recurrence, and notifications.
 * Always uses Config\App::$appTimezone (also applied by CI4 as PHP's default timezone).
 */
final class AppClock
{
    public static function timezone(): DateTimeZone
    {
        return new DateTimeZone(app_timezone());
    }

    public static function now(): DateTimeImmutable
    {
        return new DateTimeImmutable('now', self::timezone());
    }

    public static function today(): DateTimeImmutable
    {
        return self::now()->setTime(0, 0, 0);
    }

    public static function parse(string $value): DateTimeImmutable
    {
        return new DateTimeImmutable($value, self::timezone());
    }
}
