Skip to content

Commit

Permalink
date changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nczirjak-acdh committed Aug 4, 2022
1 parent a290ceb commit 602d4ab
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/TwigExtension/ArcheTwigDateExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ public function getFilters()
return [ new \Twig_SimpleFilter('archeTranslateDateFilter', function ($value, $dateformat) {
(isset($_SESSION['language'])) ? $lang = strtolower($_SESSION['language']) : $lang = "en";

if (strpos($value, "Z") !== false) {
$value = str_replace("Z", "", $value);
}
if ($this->checkYearIsMoreThanFourDigit($value)) {
return $this->notNormalDate($value, $lang, $dateformat);
}
Expand All @@ -27,7 +30,7 @@ public function getName()

private function checkYearIsMoreThanFourDigit($value): bool
{
$explode = explode("-", $value);
$explode = explode("-", $value);
if (strlen($explode[0]) > 4) {
return true;
}
Expand All @@ -42,8 +45,13 @@ private function checkYearIsMoreThanFourDigit($value): bool
* @return string
*/
private function returnFormattedDate($dateformat, $value, $lang): string
{
{
$cal = \IntlCalendar::fromDateTime($value." Europe/Vienna");

if($cal === null ) {
return "";
}

if ($lang == 'de') {
return \IntlDateFormatter::formatObject($cal, $dateformat, 'de_DE');
}
Expand Down

0 comments on commit 602d4ab

Please sign in to comment.