You are here

function datex_format in Datex 7.3

Same name and namespace in other branches
  1. 7 datex_api/datex_api.module \datex_format()
  2. 7.2 datex_api/datex_api.class.inc \datex_format()

Deprecated but kept from datex 2.

$locale is entirely ignored and set to 'persian' as it was the sole calendar implemented by old datex.

1 call to datex_format()
datex_format_date in ./datex.module
Deprecated but kept from datex 2. Delegates to datex_format().

File

./datex.module, line 605
Datex main module file, Datex adds php-intl support to drupal.

Code

function datex_format($ignore = NULL, $datetime = NULL, $format = NULL, $tz = NULL) {
  $cal = datex_factory($tz, 'persian', 'fa');
  if (!$cal) {
    return NULL;
  }
  if (is_array($datetime)) {
    foreach ([
      'year',
      'month',
      'day',
    ] as $name) {
      if (!isset($datetime[$name])) {
        $datetime[$name] = 1;
      }
    }
    $cal
      ->setDateLocale(isset($datetime['year']) ? $datetime['year'] : 1, isset($datetime['month']) ? $datetime['month'] : 1, isset($datetime['day']) ? $datetime['day'] : 1);
    $cal
      ->setTime(isset($datetime['hour']) ? $datetime['hour'] : 12, isset($datetime['minute']) ? $datetime['minute'] : 0, isset($datetime['second']) ? $datetime['second'] : 0);
  }
  elseif (is_object($datetime)) {
    $cal
      ->setTimestamp($datetime
      ->getTimestamp());
  }
  elseif (is_numeric($datetime)) {
    $cal
      ->setTimestamp($datetime);
  }
  if (!$format) {
    $format = 'Y/m/d';
  }
  return $cal
    ->format($format);
}