pixelfed/tests/Unit/DateTimeTest.php

33 lines
873 B
PHP
Raw Normal View History

2021-02-13 05:50:46 +00:00
<?php
namespace Tests\Unit;
use Carbon\Carbon;
2022-12-21 21:21:07 +00:00
use DateTime;
2021-02-13 05:50:46 +00:00
use Tests\TestCase;
class DateTimeTest extends TestCase
{
2022-12-21 21:21:07 +00:00
/** @test */
public function mastodonTimestamp()
{
$ts = Carbon::createFromFormat(DateTime::ISO8601, '2019-09-16T02:41:57Z');
$this->assertEquals(9, $ts->month);
$this->assertEquals(16, $ts->day);
$this->assertEquals(2019, $ts->year);
$this->assertEquals(2, $ts->hour);
$this->assertEquals(41, $ts->minute);
}
2021-02-13 05:50:46 +00:00
2022-12-21 21:21:07 +00:00
/** @test */
public function p3kTimestamp()
{
$ts = Carbon::createFromFormat(DateTime::ISO8601, '2019-09-16T08:40:55+10:00');
$this->assertEquals(9, $ts->month);
$this->assertEquals(16, $ts->day);
$this->assertEquals(2019, $ts->year);
$this->assertEquals(8, $ts->hour);
$this->assertEquals(40, $ts->minute);
}
2021-02-13 05:50:46 +00:00
}