diff --git a/src/TwigExtension/ArcheTwigDateExtension.php b/src/TwigExtension/ArcheTwigDateExtension.php index e824fe9d..56b87334 100644 --- a/src/TwigExtension/ArcheTwigDateExtension.php +++ b/src/TwigExtension/ArcheTwigDateExtension.php @@ -12,7 +12,7 @@ public function getFilters() if ($this->checkYearIsMoreThanFourDigit($value)) { return $this->notNormalDate($value, $lang, $dateformat); } - return $this->returnFormattedDate($this->extendDateFormat($dateformat), $value, $lang); + return $this->returnFormattedDate($dateformat, $value, $lang); }) ]; } @@ -25,20 +25,6 @@ public function getName() return 'acdh_repo_gui.twig_extension'; } - /** - * change the datefomat to work with strftime - * - * @param string $dateformat - * @return string - */ - private function extendDateFormat(string $dateFormat): string - { - $search = array('Y', 'y', 'M', 'm', 'D', 'd'); - $replace = array('%Y', '%y', '%b', '%m', '%d', '%d'); - - return str_replace($search, $replace, $dateFormat); - } - private function checkYearIsMoreThanFourDigit($value): bool { $explode = explode("-", $value); @@ -57,13 +43,13 @@ private function checkYearIsMoreThanFourDigit($value): bool */ private function returnFormattedDate($dateformat, $value, $lang): string { + $cal = \IntlCalendar::fromDateTime($value." Europe/Vienna"); if ($lang == 'de') { - setlocale(LC_TIME, 'de_DE.utf8'); - return strftime($dateformat, strtotime($value)); + return \IntlDateFormatter::formatObject($cal, $dateformat, 'de_DE'); } - - setlocale(LC_TIME, 'en_US.utf8'); - return strftime($dateformat, strtotime($value)); + return \IntlDateFormatter::formatObject($cal, $dateformat, 'en_US'); + //setlocale(LC_TIME, 'en_US.utf8'); + //return strftime($dateformat, strtotime($value)); } diff --git a/templates/acdh-repo-gui-child.html.twig b/templates/acdh-repo-gui-child.html.twig index 8cef5c1a..cc7247a6 100644 --- a/templates/acdh-repo-gui-child.html.twig +++ b/templates/acdh-repo-gui-child.html.twig @@ -85,7 +85,7 @@ {{ "Available Date"|trans }}: {{ include('/modules/contrib/arche-gui/templates/helpers/helper-date.html.twig', - {'value': item.getData('acdh:hasAvailableDate')[0], 'dateformat': 'd M Y' } ) }} + {'value': item.getData('acdh:hasAvailableDate')[0], 'dateformat': 'd MMM Y' } ) }} {% endif%} {% if item.getData('acdh:hasAvailableDate')[0].value and item.getData('acdh:hasVersion')[0].value %} diff --git a/templates/acdh-repo-gui-detail-basic.html.twig b/templates/acdh-repo-gui-detail-basic.html.twig index f1eb6563..480f48ce 100644 --- a/templates/acdh-repo-gui-detail-basic.html.twig +++ b/templates/acdh-repo-gui-detail-basic.html.twig @@ -36,19 +36,19 @@ 'icon': 'today', 'label': 'Created Start Date', 'type': 'date', - 'dateformat': 'd M Y' + 'dateformat': 'd MMM Y' }, 'acdh:hasCreatedEndDate': { 'icon': 'today', 'label': 'Created End Date', 'type': 'date', - 'dateformat': 'd M Y' + 'dateformat': 'd MMM Y' }, 'acdh:hasAvailableDate': { 'icon': 'today', 'label': 'Available Date', 'type': 'date', - 'dateformat': 'd M Y' + 'dateformat': 'd MMM Y' }, 'acdh:hasExtent': { 'icon': 'dehaze', diff --git a/templates/acdh-repo-gui-detail-project.html.twig b/templates/acdh-repo-gui-detail-project.html.twig index 2609bd42..1ec79fc1 100644 --- a/templates/acdh-repo-gui-detail-project.html.twig +++ b/templates/acdh-repo-gui-detail-project.html.twig @@ -20,13 +20,13 @@ set properties = { 'icon': 'today', 'label': 'Start Date', 'type': 'date', - 'dateformat': 'd M Y' + 'dateformat': 'd MMM Y' }, 'acdh:hasEndDate': { 'icon': 'today', 'label': 'End Date', 'type': 'date', - 'dateformat': 'd M Y' + 'dateformat': 'd MMM Y' }, 'acdh:hasLanguage': { 'icon': 'flag', diff --git a/templates/acdh-repo-gui-detail-versions-block.html.twig b/templates/acdh-repo-gui-detail-versions-block.html.twig index 3e4c37aa..58471440 100644 --- a/templates/acdh-repo-gui-detail-versions-block.html.twig +++ b/templates/acdh-repo-gui-detail-versions-block.html.twig @@ -20,7 +20,7 @@ {% for key, value in result %} {% set versionTxt = '' %}