diff --git a/src/API/ConfigurationController.php b/src/API/ConfigurationController.php index 5235e133..df4173f7 100644 --- a/src/API/ConfigurationController.php +++ b/src/API/ConfigurationController.php @@ -81,6 +81,7 @@ final class ConfigurationController extends BaseApiController ->setDuration($this->formats->getDurationFormat($locale)) ->setTime($this->formats->getTimeFormat($locale)) ->setIs24hours($this->formats->isTwentyFourHours($locale)) + ->setNow($this->getDateTimeFactory()->createDateTime()) ; $view = new View($model, 200); diff --git a/src/API/Model/I18nConfig.php b/src/API/Model/I18nConfig.php index c208960e..2ccefaf0 100644 --- a/src/API/Model/I18nConfig.php +++ b/src/API/Model/I18nConfig.php @@ -88,6 +88,23 @@ final class I18nConfig * @Serializer\Type(name="boolean") */ private $is24hours = true; + /** + * The current time of the user + * + * @var \DateTime + * + * @Serializer\Expose() + * @Serializer\Groups({"Default"}) + * @Serializer\Type(name="DateTime") + */ + private $now; + + public function setNow(\DateTime $now): I18nConfig + { + $this->now = $now; + + return $this; + } public function setFormDateTime(string $formDateTime): I18nConfig { diff --git a/tests/API/ConfigurationControllerTest.php b/tests/API/ConfigurationControllerTest.php index be57f63e..f92022e8 100644 --- a/tests/API/ConfigurationControllerTest.php +++ b/tests/API/ConfigurationControllerTest.php @@ -29,13 +29,13 @@ class ConfigurationControllerTest extends APIControllerBaseTest $this->assertIsArray($result); $this->assertNotEmpty($result); - $this->assertEquals(7, \count($result)); + $this->assertEquals(8, \count($result)); $this->assertI18nStructure($result); } protected function assertI18nStructure(array $result) { - $expectedKeys = ['date', 'dateTime', 'duration', 'formDate', 'formDateTime', 'is24hours', 'time']; + $expectedKeys = ['date', 'dateTime', 'duration', 'formDate', 'formDateTime', 'is24hours', 'time', 'now']; $actual = array_keys($result); sort($actual); sort($expectedKeys);