18 declare(strict_types=1);
20 require_once(
"libs/composer/vendor/autoload.php");
30 $this->df =
$f->dateFormat();
35 $this->assertInstanceOf(
DateFormat\DateFormat::class, $this->df->standard());
36 $this->assertInstanceOf(
DateFormat\DateFormat::class, $this->df->germanShort());
37 $this->assertInstanceOf(
DateFormat\DateFormat::class, $this->df->germanLong());
38 $this->assertInstanceOf(
DateFormat\FormatBuilder::class, $this->df->custom());
44 '.',
',',
'-',
'/',
' ',
':',
'd',
'jS',
'l',
'D',
'W',
'm',
'F',
'M',
'Y',
'y',
'h',
'H',
'i',
's',
'a' 47 ->dot()->comma()->dash()->slash()->space()->colon()
48 ->day()->dayOrdinal()->weekday()->weekdayShort()
49 ->week()->month()->monthSpelled()->monthSpelledShort()
50 ->year()->twoDigitYear()
51 ->hours12()->hours24()->minutes()->seconds()->meridiem()
72 $this->expectException(InvalidArgumentException::class);
73 new DateFormat\DateFormat([
'x',
'2']);
79 $format = $this->df->germanShort();
80 $this->assertEquals(
"05.04.1985",
$format->applyTo($dt));
81 $this->assertEquals(
"05.04.1985", $dt->format((
string)
$format));
88 ->day()->dot()->month()->dot()->year()
89 ->space()->hours12()->colon()->minutes()->space()->meridiem()
91 $this->assertEquals(
"05.04.1985 09:12 pm",
$format->applyTo($dt));
92 $this->assertEquals(
"05.04.1985 09:12 pm", $dt->format((
string)
$format));
93 $format = $this->df->custom()
94 ->day()->dot()->month()->dot()->year()
95 ->space()->hours24()->colon()->minutes()->colon()->seconds()
97 $this->assertEquals(
"05.04.1985 21:12:30", $format->applyTo($dt));
102 $format = $this->df->germanShort();
103 $appended = $this->df->amend(
$format)->dot()->dot()->get();
104 $this->assertInstanceOf(
DateFormat\DateFormat::class, $appended);
106 array_merge(
$format->toArray(), [
'.',
'.']),