You are here

public static function DatexFormatter::decor in Datex 7

Translates English numbers to Persian numbers and vice versa.

Parameters

bool $decorate: If true, Returned string contains Persian numbers and if false, will contain English numbers.

2 calls to DatexFormatter::decor()
DatexFormatter::formatINTL in datex_api/datex_api_classes.inc
Formats a date according to format given.
_datex_node_edit_form_author_date_validate in ./datex.module
Element validation callback for date fields.

File

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

Class

DatexFormatter
Date tools for Jalali Dates.

Code

public static function decor($value, $decorate = FALSE) {
  static $to_en = array(
    '۱' => 1,
    '۲' => 2,
    '۳' => 3,
    '۴' => 4,
    '۵' => 5,
    '۶' => 6,
    '۷' => 7,
    '۸' => 8,
    '۹' => 9,
    '۰' => 0,
  );
  static $to_fa = array(
    1 => '۱',
    2 => '۲',
    3 => '۳',
    4 => '۴',
    5 => '۵',
    6 => '۶',
    7 => '۷',
    8 => '۸',
    9 => '۹',
    0 => '۰',
  );
  return strtr($value, $decorate ? $to_fa : $to_en);
}