From 8fb561ea20a079747f42aff38112bf1031549bbf Mon Sep 17 00:00:00 2001 From: Richard Klees Date: Mon, 23 Oct 2023 15:04:05 +0200 Subject: [PATCH] UI: remove DateTime::withFormat This functionality has become obsolete with the introduction of HTML 5 inputs for datetimes. Formatting will now be determined by the browser. --- .../class.ilIndividualAssessmentMemberGUI.php | 1 - .../ilIndividualAssessmentUserGrading.php | 2 - .../ilIndividualAssessmentUserGradingTest.php | 1 - ...lass.ilStudyProgrammeChangeDeadlineGUI.php | 4 +- ...ss.ilStudyProgrammeChangeExpireDateGUI.php | 6 +-- ...class.ilStudyProgrammeDeadlineSettings.php | 5 +-- ...alidityOfAchievedQualificationSettings.php | 4 +- .../class.ilObjTestSettingsMainGUI.php | 4 -- .../MainSettings/ilObjTestSettingsAccess.php | 2 - .../ilObjTestSettingsResultSummary.php | 1 - ...ass.ilObjTestSettingsScoringResultsGUI.php | 3 -- Modules/Test/test/ScoreSettingsTest.php | 5 +-- .../class.ilADNNotificationUIFormGUI.php | 8 +--- .../WithoutConditions/DatetimeFactory.php | 1 - .../Service/Form/class.FormAdapterGUI.php | 21 +-------- src/UI/Component/Input/Field/DateTime.php | 10 ----- src/UI/Component/Input/Field/Duration.php | 10 ----- .../Component/Input/Field/DateTime.php | 14 ------ .../Component/Input/Field/Duration.php | 45 +++---------------- .../Component/Input/Field/Renderer.php | 7 --- src/UI/examples/Input/Field/DateTime/base.php | 12 +++-- .../Input/Field/SwitchableGroup/base.php | 2 +- .../templates/default/Input/tpl.datetime.html | 4 +- .../Input/Field/DateTimeInputTest.php | 12 ----- .../Input/Field/DurationInputTest.php | 12 ----- 25 files changed, 24 insertions(+), 172 deletions(-) diff --git a/Modules/IndividualAssessment/classes/class.ilIndividualAssessmentMemberGUI.php b/Modules/IndividualAssessment/classes/class.ilIndividualAssessmentMemberGUI.php index 20773db71d90..99e798ca28b4 100644 --- a/Modules/IndividualAssessment/classes/class.ilIndividualAssessmentMemberGUI.php +++ b/Modules/IndividualAssessment/classes/class.ilIndividualAssessmentMemberGUI.php @@ -220,7 +220,6 @@ protected function buildForm( $this->lng, $this->refinery_factory, $this, - $this->user->getDateFormat(), $this->getPossibleLPStates(), $may_be_edited, $this->getObject()->getSettings()->isEventTimePlaceRequired(), diff --git a/Modules/IndividualAssessment/classes/ilIndividualAssessmentUserGrading.php b/Modules/IndividualAssessment/classes/ilIndividualAssessmentUserGrading.php index 3b9e0749de38..0a93dc97dc29 100644 --- a/Modules/IndividualAssessment/classes/ilIndividualAssessmentUserGrading.php +++ b/Modules/IndividualAssessment/classes/ilIndividualAssessmentUserGrading.php @@ -135,7 +135,6 @@ public function toFormInput( ilLanguage $lng, Refinery $refinery, AbstractCtrlAwareUploadHandler $file_handler, - \ILIAS\Data\DateFormat\DateFormat $date_format, array $grading_options, bool $may_be_edited = true, bool $place_required = false, @@ -187,7 +186,6 @@ public function toFormInput( $event_time = $input ->dateTime($lng->txt('iass_event_time')) ->withUseTime(true) - ->withFormat($date_format) ->withRequired($place_required) ->withDisabled(!$may_be_edited) ; diff --git a/Modules/IndividualAssessment/test/ilIndividualAssessmentUserGradingTest.php b/Modules/IndividualAssessment/test/ilIndividualAssessmentUserGradingTest.php index a091075a9ae0..2020117b3257 100644 --- a/Modules/IndividualAssessment/test/ilIndividualAssessmentUserGradingTest.php +++ b/Modules/IndividualAssessment/test/ilIndividualAssessmentUserGradingTest.php @@ -164,7 +164,6 @@ public function testToFormInput(): void $lng, $refinery, $file_handler, - $df->dateFormat()->standard(), [ ilIndividualAssessmentMembers::LP_IN_PROGRESS, ilIndividualAssessmentMembers::LP_FAILED, diff --git a/Modules/StudyProgramme/classes/class.ilStudyProgrammeChangeDeadlineGUI.php b/Modules/StudyProgramme/classes/class.ilStudyProgrammeChangeDeadlineGUI.php index 496be80dd70f..66189a731f05 100644 --- a/Modules/StudyProgramme/classes/class.ilStudyProgrammeChangeDeadlineGUI.php +++ b/Modules/StudyProgramme/classes/class.ilStudyProgrammeChangeDeadlineGUI.php @@ -132,15 +132,13 @@ protected function getDeadlineSubForm(ilObjStudyProgramme $prg): FormInput $option = ilObjStudyProgrammeSettingsGUI::OPT_NO_DEADLINE; $deadline_date = $prg->getSettings()->getDeadlineSettings()->getDeadlineDate(); - $format = $this->data_factory->dateFormat()->germanShort(); $deadline_date_sub_form = $ff ->dateTime('', $txt('prg_deadline_date_desc')) - ->withFormat($format) ; if ($deadline_date !== null) { $deadline_date_sub_form = $deadline_date_sub_form->withValue( - $deadline_date->format($format->toString()) + $deadline_date ); $option = ilObjStudyProgrammeSettingsGUI::OPT_DEADLINE_DATE; } diff --git a/Modules/StudyProgramme/classes/class.ilStudyProgrammeChangeExpireDateGUI.php b/Modules/StudyProgramme/classes/class.ilStudyProgrammeChangeExpireDateGUI.php index ddff933a7128..8b64ded13229 100644 --- a/Modules/StudyProgramme/classes/class.ilStudyProgrammeChangeExpireDateGUI.php +++ b/Modules/StudyProgramme/classes/class.ilStudyProgrammeChangeExpireDateGUI.php @@ -131,13 +131,11 @@ protected function getValidityOfQualificationSubForm(ilObjStudyProgramme $prg): }; $option = ilObjStudyProgrammeSettingsGUI::OPT_NO_VALIDITY_OF_QUALIFICATION; - $format = $this->data_factory->dateFormat()->germanShort(); $vq_date_sub_form = $ff - ->dateTime('', $txt('validity_qualification_date_desc')) - ->withFormat($format); + ->dateTime('', $txt('validity_qualification_date_desc')); $date = $prg->getSettings()->getValidityOfQualificationSettings()->getQualificationDate(); if ($date !== null) { - $vq_date_sub_form = $vq_date_sub_form->withValue($date->format($format->toString())); + $vq_date_sub_form = $vq_date_sub_form->withValue($date); $option = ilObjStudyProgrammeSettingsGUI::OPT_VALIDITY_OF_QUALIFICATION_DATE; } diff --git a/Modules/StudyProgramme/classes/class.ilStudyProgrammeDeadlineSettings.php b/Modules/StudyProgramme/classes/class.ilStudyProgrammeDeadlineSettings.php index c0d025a5de5a..6f57cf7141a4 100644 --- a/Modules/StudyProgramme/classes/class.ilStudyProgrammeDeadlineSettings.php +++ b/Modules/StudyProgramme/classes/class.ilStudyProgrammeDeadlineSettings.php @@ -71,8 +71,6 @@ public function toFormInput( Refinery $refinery, Factory $data_factory ): \ILIAS\UI\Component\Input\Container\Form\FormInput { - $format = $data_factory->dateFormat()->germanShort(); - $grp1 = $input->group([], $lng->txt('prg_no_deadline')); $grp2 = $input->group( [ @@ -91,8 +89,7 @@ public function toFormInput( $lng->txt('prg_deadline_date_label'), $lng->txt('prg_deadline_date_desc') ) - ->withFormat($format) - ->withValue($this->getDeadlineDate() !== null ? $this->getDeadlineDate()->format('d.m.Y') : '') + ->withValue($this->getDeadlineDate()) ->withRequired(true) ], $lng->txt('prg_deadline_date') diff --git a/Modules/StudyProgramme/classes/class.ilStudyProgrammeValidityOfAchievedQualificationSettings.php b/Modules/StudyProgramme/classes/class.ilStudyProgrammeValidityOfAchievedQualificationSettings.php index 5478f95d9f57..36f052d10426 100644 --- a/Modules/StudyProgramme/classes/class.ilStudyProgrammeValidityOfAchievedQualificationSettings.php +++ b/Modules/StudyProgramme/classes/class.ilStudyProgrammeValidityOfAchievedQualificationSettings.php @@ -111,7 +111,6 @@ public function toFormInput( Refinery $refinery, Factory $data_factory ): \ILIAS\UI\Component\Input\Container\Form\FormInput { - $format = $data_factory->dateFormat()->germanShort(); $grp1 = $input->group([], $lng->txt('prg_no_validity_qualification')); $grp2 = $input->group( [ @@ -130,8 +129,7 @@ public function toFormInput( $lng->txt('vq_date_label'), $lng->txt('validity_qualification_date_desc') ) - ->withFormat($format) - ->withValue($this->getQualificationDate() !== null ? $this->getQualificationDate()->format('d.m.Y') : '') + ->withValue($this->getQualificationDate()) ->withRequired(true) ], $lng->txt('validity_qualification_date') diff --git a/Modules/Test/classes/MainSettings/class.ilObjTestSettingsMainGUI.php b/Modules/Test/classes/MainSettings/class.ilObjTestSettingsMainGUI.php index 3aa94f138e05..924f4d023cbd 100644 --- a/Modules/Test/classes/MainSettings/class.ilObjTestSettingsMainGUI.php +++ b/Modules/Test/classes/MainSettings/class.ilObjTestSettingsMainGUI.php @@ -253,7 +253,6 @@ private function buildForm(string $form_command = self::CMD_SAVE_FORM): Standard $user_format = $this->activeUser->getDateFormat(); $environment['participant_data_exists'] = $this->test_object->participantDataExist(); - $environment['user_date_format'] = $data_factory->dateFormat()->withTime24($user_format); $environment['user_time_zone'] = $this->activeUser->getTimeZone(); $main_inputs = [ @@ -464,12 +463,9 @@ private function getTimebasedAvailabilityInputs(): OptionalGroup $value = $this->getValueForActivationLimitedOptionalGroup(); $data_factory = new DataFactory(); - $user_format = $this->activeUser->getDateFormat(); - $format = $data_factory->dateFormat()->withTime24($user_format); $inputs['time_span'] = $field_factory->duration($this->lng->txt('rep_time_period')) ->withTimezone($this->activeUser->getTimeZone()) - ->withFormat($format) ->withUseTime(true) ->withRequired(true); $inputs['activation_visibility'] = $field_factory->checkbox( diff --git a/Modules/Test/classes/MainSettings/ilObjTestSettingsAccess.php b/Modules/Test/classes/MainSettings/ilObjTestSettingsAccess.php index 5855541befe8..5bebdd0811b3 100644 --- a/Modules/Test/classes/MainSettings/ilObjTestSettingsAccess.php +++ b/Modules/Test/classes/MainSettings/ilObjTestSettingsAccess.php @@ -113,7 +113,6 @@ private function getSubInputsAccessWindow( $lng->txt('tst_starting_time'), $lng->txt('tst_starting_time_desc') )->withTimezone($environment['user_time_zone']) - ->withFormat($environment['user_date_format']) ->withUseTime(true); if ($this->getStartTime() !== null) { $sub_inputs_access_window['start_time'] = $sub_inputs_access_window['start_time'] @@ -127,7 +126,6 @@ private function getSubInputsAccessWindow( $lng->txt('tst_ending_time'), $lng->txt('tst_ending_time_desc') )->withTimezone($environment['user_time_zone']) - ->withFormat($environment['user_date_format']) ->withUseTime(true); if ($this->getEndTime() !== null) { $sub_inputs_access_window['end_time'] = $sub_inputs_access_window['end_time'] diff --git a/Modules/Test/classes/ScoreReporting/ilObjTestSettingsResultSummary.php b/Modules/Test/classes/ScoreReporting/ilObjTestSettingsResultSummary.php index 52174c74a95e..eb51ec63fe8e 100644 --- a/Modules/Test/classes/ScoreReporting/ilObjTestSettingsResultSummary.php +++ b/Modules/Test/classes/ScoreReporting/ilObjTestSettingsResultSummary.php @@ -73,7 +73,6 @@ function ($v) { [ $f->dateTime($lng->txt('tst_reporting_date'), "") ->withTimezone($environment['user_time_zone']) - ->withFormat($environment['user_date_format']) ->withValue( $this->getReportingDate()?->setTimezone( new DateTimeZone($environment['user_time_zone']) diff --git a/Modules/Test/classes/class.ilObjTestSettingsScoringResultsGUI.php b/Modules/Test/classes/class.ilObjTestSettingsScoringResultsGUI.php index 6e5156c7116e..be8efb080285 100644 --- a/Modules/Test/classes/class.ilObjTestSettingsScoringResultsGUI.php +++ b/Modules/Test/classes/class.ilObjTestSettingsScoringResultsGUI.php @@ -184,9 +184,6 @@ private function buildForm(): Form $environment = []; - $environment['user_date_format'] = (new \ILIAS\Data\Factory())->dateFormat()->withTime24( - $this->active_user->getDateFormat() - ); $environment['user_time_zone'] = $this->active_user->getTimeZone(); $anonymity_flag = (bool) $this->test_object->getAnonymity(); diff --git a/Modules/Test/test/ScoreSettingsTest.php b/Modules/Test/test/ScoreSettingsTest.php index dd626e7ae892..2807d38059e9 100644 --- a/Modules/Test/test/ScoreSettingsTest.php +++ b/Modules/Test/test/ScoreSettingsTest.php @@ -254,10 +254,7 @@ public function testScoreSettingsSectionSummary(): void $s = new ilObjTestSettingsResultSummary(666); $actual = $this->getDefaultRenderer()->render( $s->toForm(...array_merge($ui, [[ - 'user_time_zone' => 'Europe/Berlin', - 'user_date_format' => $data_factory->dateFormat()->withTime24( - $data_factory->dateFormat()->standard() - ) + 'user_time_zone' => 'Europe/Berlin' ]])) ); diff --git a/Services/AdministrativeNotification/classes/class.ilADNNotificationUIFormGUI.php b/Services/AdministrativeNotification/classes/class.ilADNNotificationUIFormGUI.php index 7e51044f0da3..e84660b597f8 100644 --- a/Services/AdministrativeNotification/classes/class.ilADNNotificationUIFormGUI.php +++ b/Services/AdministrativeNotification/classes/class.ilADNNotificationUIFormGUI.php @@ -102,8 +102,8 @@ public function getHTML(): string public function initForm(): void { $field = $this->ui->input()->field(); - $custom_trafo = fn (callable $c): Transformation => $this->refinery->custom()->transformation($c); - $custom_constraint = fn (callable $c, string $error): Transformation => $this->refinery->custom()->constraint( + $custom_trafo = fn(callable $c): Transformation => $this->refinery->custom()->transformation($c); + $custom_constraint = fn(callable $c, string $error): Transformation => $this->refinery->custom()->constraint( $c, $error ); @@ -148,7 +148,6 @@ public function initForm(): void $display_date_start = $field->dateTime($this->txt(self::F_DISPLAY_DATE_START)) ->withUseTime(true) - ->withFormat($format) ->withValue($this->notification->getDisplayStart()->format($str)) ->withAdditionalTransformation( $custom_trafo(function (?DateTimeImmutable $v): ?\DateTimeImmutable { @@ -158,7 +157,6 @@ public function initForm(): void ); $display_date_end = $field->dateTime($this->txt(self::F_DISPLAY_DATE_END)) ->withUseTime(true) - ->withFormat($format) ->withValue($this->notification->getDisplayEnd()->format($str)) ->withAdditionalTransformation( $custom_trafo(function (?DateTimeImmutable $v): ?\DateTimeImmutable { @@ -168,7 +166,6 @@ public function initForm(): void ); $event_date_start = $field->dateTime($this->txt(self::F_EVENT_DATE_START)) ->withUseTime(true) - ->withFormat($format) ->withValue($this->notification->getEventStart()->format($str)) ->withAdditionalTransformation( $custom_trafo(function (?DateTimeImmutable $v): ?\DateTimeImmutable { @@ -178,7 +175,6 @@ public function initForm(): void ); $event_date_end = $field->dateTime($this->txt(self::F_EVENT_DATE_END)) ->withUseTime(true) - ->withFormat($format) ->withValue($this->notification->getEventEnd()->format($str)) ->withAdditionalTransformation( $custom_trafo(function (?DateTimeImmutable $v): ?\DateTimeImmutable { diff --git a/Services/MetaData/classes/Editor/Full/Services/Inputs/WithoutConditions/DatetimeFactory.php b/Services/MetaData/classes/Editor/Full/Services/Inputs/WithoutConditions/DatetimeFactory.php index ebf373cc6e56..4600ba176749 100644 --- a/Services/MetaData/classes/Editor/Full/Services/Inputs/WithoutConditions/DatetimeFactory.php +++ b/Services/MetaData/classes/Editor/Full/Services/Inputs/WithoutConditions/DatetimeFactory.php @@ -54,7 +54,6 @@ protected function rawInput( $dh = $this->data_helper; return $this->ui_factory ->dateTime('placeholder') - ->withFormat($this->presenter->utilities()->getUserDateFormat()) ->withAdditionalTransformation( $this->refinery->custom()->transformation( function ($v) use ($dh) { diff --git a/Services/Repository/Service/Form/class.FormAdapterGUI.php b/Services/Repository/Service/Form/class.FormAdapterGUI.php index ebc651677c84..f1e02762ac98 100644 --- a/Services/Repository/Service/Form/class.FormAdapterGUI.php +++ b/Services/Repository/Service/Form/class.FormAdapterGUI.php @@ -260,28 +260,9 @@ public function date( ): self { $field = $this->ui->factory()->input()->field()->dateTime($title, $description); - $format = $this->user->getDateFormat(); - $dt_format = (string) $format; - /* - switch ((int) $this->user->getDateFormat()) { - case \ilCalendarSettings::DATE_FORMAT_DMY: - $format = $this->data->dateFormat()->germanShort(); - $dt_format = "d.m.Y"; - break; - case \ilCalendarSettings::DATE_FORMAT_MDY: - $format = $this->data->dateFormat()->custom()->month()->slash()->day()->slash()->year(); - $dt_format = "m/d/Y"; - break; - default: - $format = $this->data->dateFormat()->standard(); - $dt_format = "Y-m-d"; - break; - }*/ - - $field = $field->withFormat($format); if (!is_null($value)) { $field = $field->withValue( - (new \DateTime($value->get(IL_CAL_DATE)))->format($dt_format) + (new \DateTime($value->get(IL_CAL_DATE)))->format("Y-m-d") ); } $this->addField($key, $field); diff --git a/src/UI/Component/Input/Field/DateTime.php b/src/UI/Component/Input/Field/DateTime.php index 29384a2e0da0..5591308771de 100644 --- a/src/UI/Component/Input/Field/DateTime.php +++ b/src/UI/Component/Input/Field/DateTime.php @@ -30,16 +30,6 @@ */ interface DateTime extends FormInput { - /** - * Get an input like this using the given format. - */ - public function withFormat(DateFormat $format): self; - - /** - * Get the date-format of this input. - */ - public function getFormat(): DateFormat; - /** * Get an input like this using the given timezone. */ diff --git a/src/UI/Component/Input/Field/Duration.php b/src/UI/Component/Input/Field/Duration.php index efe5b83a0f8d..bf1122a6e1af 100644 --- a/src/UI/Component/Input/Field/Duration.php +++ b/src/UI/Component/Input/Field/Duration.php @@ -29,16 +29,6 @@ */ interface Duration extends Group { - /** - * Get an input like this using the given format. - */ - public function withFormat(DateFormat $format): Duration; - - /** - * Get the date-format of this input. - */ - public function getFormat(): DateFormat; - /** * Limit accepted values to Duration past (and including) the given $Duration. */ diff --git a/src/UI/Implementation/Component/Input/Field/DateTime.php b/src/UI/Implementation/Component/Input/Field/DateTime.php index deb754726769..1b79d0cc1b16 100644 --- a/src/UI/Implementation/Component/Input/Field/DateTime.php +++ b/src/UI/Implementation/Component/Input/Field/DateTime.php @@ -40,7 +40,6 @@ class DateTime extends FormInput implements C\Input\Field\DateTime public const TIME_FORMAT = 'HH:mm'; - protected DateFormat $format; protected ?DateTimeImmutable $min_date = null; protected ?DateTimeImmutable $max_date = null; protected bool $with_time = false; @@ -94,19 +93,6 @@ public function withValue($value): self return parent::withValue($value); } - public function withFormat(DateFormat $format): self - { - $clone = clone $this; - $clone->format = $format; - return $clone; - } - - public function getFormat(): DateFormat - { - return $this->format; - } - - public function withTimezone(string $tz): self { $timezone_trafo = $this->refinery->dateTime()->changeTimezone($tz); diff --git a/src/UI/Implementation/Component/Input/Field/Duration.php b/src/UI/Implementation/Component/Input/Field/Duration.php index c63afaf02c2f..2e556b9ea953 100644 --- a/src/UI/Implementation/Component/Input/Field/Duration.php +++ b/src/UI/Implementation/Component/Input/Field/Duration.php @@ -39,7 +39,6 @@ class Duration extends Group implements C\Input\Field\Duration use ComponentHelper; use JavaScriptBindable; - protected DateFormat $format; protected DateTimeImmutable $min_date; protected DateTimeImmutable $max_date; protected bool $with_time = false; @@ -89,7 +88,7 @@ protected function addTransformation(): void protected function addValidation(): void { $txt_id = 'duration_end_must_not_be_earlier_than_start'; - $error = fn (callable $txt, $value) => $txt($txt_id, $value); + $error = fn(callable $txt, $value) => $txt($txt_id, $value); $is_ok = function ($v) { if (is_null($v)) { return true; @@ -101,36 +100,6 @@ protected function addValidation(): void $this->setAdditionalTransformation($from_before_until); } - /** - * @inheritdoc - */ - public function withFormat(DateFormat $format): C\Input\Field\Duration - { - $clone = clone $this; - $clone->format = $format; - $clone->applyFormat(); - return $clone; - } - - /** - * @inheritdoc - */ - public function getFormat(): DateFormat - { - return $this->format; - } - - /** - * apply format to inputs - */ - protected function applyFormat(): void - { - $this->inputs = array_map( - fn ($input) => $input->withFormat($this->getFormat()), - $this->inputs - ); - } - /** * @inheritdoc */ @@ -148,7 +117,7 @@ public function withMinValue(DateTimeImmutable $date): C\Input\Field\Duration protected function applyMinValue(): void { $this->inputs = array_map( - fn ($input) => $input->withMinValue($this->getMinValue()), + fn($input) => $input->withMinValue($this->getMinValue()), $this->inputs ); } @@ -178,7 +147,7 @@ public function withMaxValue(DateTimeImmutable $date): C\Input\Field\Duration protected function applyMaxValue(): void { $this->inputs = array_map( - fn ($inpt) => $inpt->withMaxValue($this->getMaxValue()), + fn($inpt) => $inpt->withMaxValue($this->getMaxValue()), $this->inputs ); } @@ -208,7 +177,7 @@ public function withTimeOnly(bool $time_only): C\Input\Field\Duration protected function applyWithTimeOnly(): void { $this->inputs = array_map( - fn ($input) => $input->withTimeOnly($this->getTimeOnly()), + fn($input) => $input->withTimeOnly($this->getTimeOnly()), $this->inputs ); } @@ -246,7 +215,7 @@ public function getUseTime(): bool protected function applyWithUseTime(): void { $this->inputs = array_map( - fn ($input) => $input->withUseTime($this->getUseTime()), + fn($input) => $input->withUseTime($this->getUseTime()), $this->inputs ); } @@ -259,7 +228,7 @@ public function withTimezone(string $tz): C\Input\Field\Duration $clone = clone $this; $clone->timezone = $tz; $clone->inputs = array_map( - fn ($input) => $input->withTimezone($tz), + fn($input) => $input->withTimezone($tz), $clone->inputs ); return $clone; @@ -298,7 +267,7 @@ protected function getConstraintForRequirement(): ?Constraint */ public function getUpdateOnLoadCode(): Closure { - return fn ($id) => "var combinedDuration = function() { + return fn($id) => "var combinedDuration = function() { var options = []; $('#$id').find('input').each(function() { options.push($(this).val()); diff --git a/src/UI/Implementation/Component/Input/Field/Renderer.php b/src/UI/Implementation/Component/Input/Field/Renderer.php index 4b279447d3d9..2f34fc7e7dab 100644 --- a/src/UI/Implementation/Component/Input/Field/Renderer.php +++ b/src/UI/Implementation/Component/Input/Field/Renderer.php @@ -645,13 +645,8 @@ protected function renderDateTimeField(F\DateTime $component, RendererInterface $dt_type = self::TYPE_TIME; } else { $dt_type = self::TYPE_DATE; - $format = $this->getTransformedDateFormat( - $component->getFormat(), - self::DATEPICKER_FORMAT_MAPPING - ); if ($component->getUseTime() === true) { - $format .= ' ' . $component::TIME_FORMAT; $dt_type = self::TYPE_DATETIME; } } @@ -672,8 +667,6 @@ protected function renderDateTimeField(F\DateTime $component, RendererInterface $tpl->setVariable("MAX_DATE", date_format($max_date, $min_max_format)); } - $tpl->setVariable("PLACEHOLDER", $format); - $this->applyValue($component, $tpl, function (?string $value) use ($dt_type) { if ($value !== null) { $value = new \DateTimeImmutable($value); diff --git a/src/UI/examples/Input/Field/DateTime/base.php b/src/UI/examples/Input/Field/DateTime/base.php index a5b4e8cc9c55..cf49527a0be8 100644 --- a/src/UI/examples/Input/Field/DateTime/base.php +++ b/src/UI/examples/Input/Field/DateTime/base.php @@ -24,7 +24,6 @@ function base() $date_now = new \DateTimeImmutable('now'); $formatted = $date ->withMinValue($date_now) - ->withFormat($data->dateFormat()->germanShort()) ->withLabel('future only') ->withByline('Only allows to pick a date in the future. It will be shown in format DD.MM.YYYY'); @@ -44,22 +43,21 @@ function base() ->withByline('Pick any date and time you want. It will be shown in format YYYY-MM-DD HH:mm and be saved for Tokyo time zone.'); //if you want a date converted to the timezone, do it on the date: - $date_now = new \DateTime('now'); - $date_zoned = new \DateTime('now', new \DateTimeZone($tz)); + $date_now = new \DateTimeImmutable('now'); + $date_zoned = new \DateTimeImmutable('now', new \DateTimeZone($tz)); //here is the usage of Data/DateFormat - $format = $timezoned->getFormat()->toString() . ' H:i'; $timezoned_preset1 = $timezoned - ->withValue($date_now->format($format)) + ->withValue($date_now) ->withLabel('to Tokyo time with local preset') ->withByline('Local time+date is preset. However, output will be in Tokyo timezone'); $timezoned_preset2 = $timezoned - ->withValue($date_zoned->format($format)) + ->withValue($date_zoned) ->withLabel('Tokyo time, both preset and output') ->withByline('Tokyo time+date is preset. Output is also Tokyo time.'); $disabled = $date - ->withValue($date_now->format($timezoned->getFormat()->toString())) + ->withValue($date_now) ->withDisabled(true) ->withLabel('disabled') ->withByline('You cannot pick anything, as the field is disabled'); diff --git a/src/UI/examples/Input/Field/SwitchableGroup/base.php b/src/UI/examples/Input/Field/SwitchableGroup/base.php index acc627b9132d..cbdaa993cc66 100644 --- a/src/UI/examples/Input/Field/SwitchableGroup/base.php +++ b/src/UI/examples/Input/Field/SwitchableGroup/base.php @@ -21,7 +21,7 @@ function base() [ "field_1_1" => $ui->input()->field()->text("Item 1.1", "Just some field"), "field_1_2" => $ui->input()->field()->text("Item 1.2", "Just some other field"), - "field_1_3" => $ui->input()->field()->datetime("Item 1.3", "a date")->withFormat($data->dateFormat()->germanShort()) + "field_1_3" => $ui->input()->field()->datetime("Item 1.3", "a date") ], "Switchable Group number one (with numeric key)" ); diff --git a/src/UI/templates/default/Input/tpl.datetime.html b/src/UI/templates/default/Input/tpl.datetime.html index e1690a2c41d2..93a522f93fb0 100644 --- a/src/UI/templates/default/Input/tpl.datetime.html +++ b/src/UI/templates/default/Input/tpl.datetime.html @@ -1,5 +1,5 @@
type="{DTTYPE}" value="{VALUE}" name="{NAME}" - min="{MIN_DATE}" max="{MAX_DATE}" placeholder="{PLACEHOLDER}" + min="{MIN_DATE}" max="{MAX_DATE}" disabled="{DISABLED}" class="form-control form-control-sm" /> -
\ No newline at end of file + diff --git a/tests/UI/Component/Input/Field/DateTimeInputTest.php b/tests/UI/Component/Input/Field/DateTimeInputTest.php index 05f1fca9c6a1..25d20089f7d7 100644 --- a/tests/UI/Component/Input/Field/DateTimeInputTest.php +++ b/tests/UI/Component/Input/Field/DateTimeInputTest.php @@ -79,18 +79,6 @@ protected function buildFactory(): I\Input\Field\Factory ); } - public function testWithFormat(): void - { - $format = $this->data_factory->dateFormat()->germanShort(); - $datetime = $this->factory->datetime('label', 'byline') - ->withFormat($format); - - $this->assertEquals( - $format, - $datetime->getFormat() - ); - } - public function testWithMinValue(): void { $dat = new DateTimeImmutable('2019-01-09'); diff --git a/tests/UI/Component/Input/Field/DurationInputTest.php b/tests/UI/Component/Input/Field/DurationInputTest.php index 7a5265ea59fe..fb36cd230d21 100644 --- a/tests/UI/Component/Input/Field/DurationInputTest.php +++ b/tests/UI/Component/Input/Field/DurationInputTest.php @@ -81,18 +81,6 @@ public function symbol(): C\Symbol\Factory }; } - public function testWithFormat(): void - { - $format = $this->data_factory->dateFormat()->germanShort(); - $duration = $this->factory->duration('label', 'byline') - ->withFormat($format); - - $this->assertEquals( - $format, - $duration->getFormat() - ); - } - public function testWithMinValue(): void { $dat = new DateTimeImmutable('2019-01-09');