Skip to content

Commit

Permalink
CalendarField: changing strftime to date (#44114)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hackwar authored Nov 13, 2024
1 parent cb0c4c8 commit 26c9f50
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libraries/src/Form/Field/CalendarField.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\Registry\Registry;

Expand Down Expand Up @@ -320,7 +321,7 @@ protected function getInput()
$date = \DateTimeImmutable::createFromFormat('U', strtotime($value));
$value = $date->format($this->filterFormat);
} else {
$value = strftime($this->format, strtotime($value));
$value = date(HTMLHelper::strftimeFormatToDateFormat($this->format), strtotime($value));
}

date_default_timezone_set($tz);
Expand Down
24 changes: 24 additions & 0 deletions libraries/src/HTML/HTMLHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,18 @@ public static function strftimeFormatToDateFormat(string $strftimeformat)
'%H',
'%M',
'%S',
'%a',
'%A',
'%e',
'%j',
'%u',
'%w',
'%W',
'%b',
'%B',
'%h',
'%g',
'%I',
],
[
'Y',
Expand All @@ -1279,6 +1291,18 @@ public static function strftimeFormatToDateFormat(string $strftimeformat)
'H',
'i',
's',
'D',
'l',
'j',
'z',
'N',
'w',
'W',
'M',
'F',
'M',
'y',
'h',
],
$strftimeformat
);
Expand Down

0 comments on commit 26c9f50

Please sign in to comment.