diff --git a/config/packages/kimai.yaml b/config/packages/kimai.yaml index 59f46ed8..b4d8f6ee 100644 --- a/config/packages/kimai.yaml +++ b/config/packages/kimai.yaml @@ -169,8 +169,8 @@ kimai: hu: date_time_type: 'yyyy.MM.dd HH:mm' date_time_picker: 'YYYY.MM.DD HH:mm' - date_type: 'yyyy.MM.dd' - date_picker: 'YYYY.MM.DD' + date_type: 'yyyy.MM.dd.' + date_picker: 'YYYY.MM.DD.' date: 'Y.m.d.' date_time: 'm.d. H:i' duration: '%%h:%%m h' diff --git a/src/Form/Type/DateRangeType.php b/src/Form/Type/DateRangeType.php index 1c4a1837..6b31821a 100644 --- a/src/Form/Type/DateRangeType.php +++ b/src/Form/Type/DateRangeType.php @@ -67,8 +67,46 @@ class DateRangeType extends AbstractType }); } + /** + * A better way would be to use the Intl NumberFormatter, but if that is not available + * and the Symfony polyfill is used, this method would not work properly. + * + * @param $string + * @return string + */ + protected function convertArabicPersian($string) + { + return strtr( + $string, + [ + '۰' => '0', + '۱' => '1', + '۲' => '2', + '۳' => '3', + '۴' => '4', + '۵' => '5', + '۶' => '6', + '۷' => '7', + '۸' => '8', + '۹' => '9', + '٠' => '0', + '١' => '1', + '٢' => '2', + '٣' => '3', + '٤' => '4', + '٥' => '5', + '٦' => '6', + '٧' => '7', + '٨' => '8', + '٩' => '9' + ] + ); + } + protected function formatToPattern(string $format, string $separator) { + $format = preg_quote($format, '/'); + $pattern = str_replace('d', '[0-9]{2}', $format); $pattern = str_replace('m', '[0-9]{2}', $pattern); $pattern = str_replace('Y', '[0-9]{4}', $pattern); @@ -105,6 +143,8 @@ class DateRangeType extends AbstractType return $range; } + $dates = $this->convertArabicPersian($dates); + if (preg_match($pattern, $dates) !== 1) { throw new TransformationFailedException('Invalid date range given'); }