You are here

public static function DatexFormatter::phpToIntl in Datex 7

Converts date format string (like 'Y-m-d') to it's PHP-Intl equivilant.

Parameters

string $format: Format accepted by php date_format.

Return value

string Format accepted by PHP-Intl date formatter (ICU).

1 call to DatexFormatter::phpToIntl()
DatexFormatter::formatINTL in datex_api/datex_api_classes.inc
Formats a date according to format given.

File

datex_api/datex_api_classes.inc, line 217
API and helper functions used by other datex modules.

Class

DatexFormatter
Date tools for Jalali Dates.

Code

public static function phpToIntl($format) {
  static $format_map = NULL;
  if (!$format_map) {
    $format_map = array(
      'd' => 'dd',
      'D' => 'EEE',
      'j' => 'd',
      'l' => 'EEEE',
      'N' => 'e',
      'S' => 'LLLL',
      'w' => '',
      'z' => 'D',
      'W' => 'w',
      'm' => 'MM',
      'M' => 'MMM',
      'F' => 'MMMM',
      'n' => 'M',
      't' => '',
      'L' => '',
      'o' => 'yyyy',
      'y' => 'yy',
      'Y' => 'YYYY',
      'a' => 'a',
      'A' => 'a',
      'B' => '',
      'g' => 'h',
      'G' => 'H',
      'h' => 'hh',
      'H' => 'HH',
      'i' => 'mm',
      's' => 'ss',
      'u' => 'SSSSSS',
      'e' => 'z',
      'I' => '',
      'O' => 'Z',
      'P' => 'ZZZZ',
      'T' => 'v',
      'Z' => '',
      'c' => '',
      'r' => '',
      'U' => '',
      ' ' => ' ',
      '-' => '-',
      '.' => '.',
      '-' => '-',
      ':' => ':',
    );
  }
  $replace_pattern = '/[^ \\:\\-\\/\\.\\\\dDjlNSwzWmMFntLoyYaABgGhHisueIOPTZcrU]/';
  return strtr(preg_replace($replace_pattern, '', $format), $format_map);
}