<?php declare(strict_types=1);

// Utility methods.
final class QrbDateTime
{
    private const DATE_TIME_ZONE_ZURICH = "Europe/Zurich";
    
    // Creates a time stamp used for example as part of the log file name (formatted local date).
    public static function createDateStamp(DateTimeInterface $date) : string
    {
        $dateTimeZone = new DateTimeZone(self::DATE_TIME_ZONE_ZURICH);
        return $date->setTimezone($dateTimeZone)->format('Ymd');
    }

    // Creates a time stamp used for example as the output folder name (formatted local date).
    public static function createTimeStamp(DateTimeInterface $date) : string
    {
        $dateTimeZone = new DateTimeZone(self::DATE_TIME_ZONE_ZURICH);
        return $date->setTimezone($dateTimeZone)->format('Ymd-His');
    }

    // Creates a time stamp used for the prefix in log output (formatted local date followed by ": ").
    public static function createTimeStampForLog(DateTimeInterface $date) : string
    {
        $dateTimeZone = new DateTimeZone(self::DATE_TIME_ZONE_ZURICH);
        return $date->setTimezone($dateTimeZone)->format('Y-m-d H:i:s.u: ');
    }

    // Creates a human readable time stamp (formatted local date).
    public static function createHumanReadableTimeStamp(DateTimeInterface $date) : string
    {
        $dateTimeZone = new DateTimeZone(self::DATE_TIME_ZONE_ZURICH);
        return $date->setTimezone($dateTimeZone)->format('Y-m-d_H:i:s');
    }
}

?>
