You are here

private static function DatexIntlCalendar::toGregorian in Datex 8

1 call to DatexIntlCalendar::toGregorian()
DatexIntlCalendar::setDateLocale in src/Datex/DatexIntlCalendar.php

File

src/Datex/DatexIntlCalendar.php, line 126

Class

DatexIntlCalendar

Namespace

Drupal\datex\Datex

Code

private static function toGregorian(\IntlDateFormatter $fmt, $tz, $y, $m, $d) {
  $fmt
    ->setPattern(static::format2pattern('n/j/Y H:i:s'));
  $fmt
    ->setLenient(TRUE);
  $ts = $fmt
    ->parse($m . '/' . $d . '/' . $y . ' 12:00:00');
  $d = new \DateTime('@' . $ts, $tz);
  return [
    $d
      ->format('Y'),
    $d
      ->format('n'),
    $d
      ->format('j'),
  ];
}