ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
Factory.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Data\DateFormat;
22 
26 class Factory
27 {
29 
30  public function __construct(FormatBuilder $builder)
31  {
32  $this->builder = $builder;
33  }
34 
38  public function standard(): DateFormat
39  {
40  return $this->builder->year()->dash()->month()->dash()->day()->get();
41  }
42 
46  public function custom(): FormatBuilder
47  {
48  return $this->builder;
49  }
50 
52  {
53  return $this->builder->initWithFormat($format);
54  }
55 
56  public function germanShort(): DateFormat
57  {
58  return $this->builder->day()->dot()->month()->dot()->year()->get();
59  }
60 
61  public function germanLong(): DateFormat
62  {
63  return $this->builder->weekday()->comma()->space()
64  ->day()->dot()->month()->dot()->year()->get();
65  }
66 
68  {
69  return $this->amend($format)
70  ->space()->hours12()->colon()->minutes()->space()->meridiem()->get();
71  }
72 
74  {
75  return $this->amend($format)
76  ->space()->hours24()->colon()->minutes()->get();
77  }
78 }
standard()
Get the ISO 8601 date format (YYYY-MM-DD)
Definition: Factory.php:38
__construct(FormatBuilder $builder)
Definition: Factory.php:30
custom()
Get the builder to define a custom DateFormat.
Definition: Factory.php:46
Builds a Date Format with split up elements to ease conversion.
withTime24(DateFormat $format)
Definition: Factory.php:73
withTime12(DateFormat $format)
Definition: Factory.php:67
A Date Format provides a format definition akin to PHP&#39;s date formatting options, but stores the sing...
Definition: DateFormat.php:26
$format
Definition: metadata.php:235
amend(DateFormat $format)
Definition: Factory.php:51