<?php declare(strict_types=1);

require_once __DIR__ . '/../../src/common/QrbDateTime.php';

use PHPUnit\Framework\TestCase;

final class QrbDateTimeTest extends TestCase
{
    public function testCreateDateStamp()
    {
        $date = new DateTime();
        $date->setDate(2024,12,31);
        $this->assertEquals("20241231", QrbDateTime::createDateStamp($date));
    }

    public function testCreateTimeStamp()
    {
        $date = new DateTime();
        $date->setTimezone(new DateTimeZone("Europe/Zurich"));
        $date->setDate(2024,12,31);
        $date->setTime(23,59,59,0);
        $this->assertEquals("20241231-235959", QrbDateTime::createTimeStamp($date));
    }

    public function testCreateTimeStampForLog()
    {
        $date = new DateTime();
        $date->setTimezone(new DateTimeZone("Europe/Zurich"));
        $date->setDate(2024,12,31);
        $date->setTime(23,59,59,0);
        $this->assertEquals("2024-12-31 23:59:59.000000: ", QrbDateTime::createTimeStampForLog($date));
    }

    public function testCreateHumanReadableTimeStamp()
    {
        $date = new DateTime();
        $date->setTimezone(new DateTimeZone("Europe/Zurich"));
        $date->setDate(2024,12,31);
        $date->setTime(23,59,59,0);
        $this->assertEquals("2024-12-31_23:59:59", QrbDateTime::createHumanReadableTimeStamp($date));
    }
}

?>
