Static Public Member Functions | Data Fields | Static Protected Member Functions

Zend_Locale_Format Class Reference

Static Public Member Functions

static setOptions (array $options=array())
static convertNumerals ($input, $from, $to=null)
static getNumber ($input, array $options=array())
static toNumber ($value, array $options=array())
static isNumber ($input, array $options=array())
static getFloat ($input, array $options=array())
static toFloat ($value, array $options=array())
static isFloat ($value, array $options=array())
static getInteger ($input, array $options=array())
static toInteger ($value, array $options=array())
static isInteger ($value, array $options=array())
static convertPhpToIsoFormat ($format)
static getDateFormat ($locale=null)
static getDate ($date, array $options=array())
static checkDateFormat ($date, array $options=array())
static getTimeFormat ($locale=null)
static getTime ($time, array $options=array())
static getDateTimeFormat ($locale=null)
static getDateTime ($datetime, array $options=array())

Data Fields

const STANDARD = 'auto'

Static Protected Member Functions

static _replaceMonth (&$number, $monthlist)

Detailed Description

Definition at line 35 of file Format.php.


Member Function Documentation

static _replaceMonth ( &$  number,
monthlist 
) [static, protected]

Search $number for a month name found in $monthlist, and replace if found.

Parameters:
string$numberDate string (modified)
array$monthlistList of month names
Returns:
int|false Position of replaced string (false if nothing replaced)

Definition at line 1061 of file Format.php.

static checkDateFormat ( date,
array $  options = array() 
) [static]

Returns if the given datestring contains all date parts from the given format. If no format is given, the default date format from the locale is used If you want to check if the date is a proper date you should use Zend_Date::isDate()

Parameters:
string$dateDate string
array$optionsOptions: format_type, fix_date, locale, date_format. See setOptions() for details.
Returns:
boolean

Definition at line 1128 of file Format.php.

static convertNumerals ( input,
from,
to = null 
) [static]

Changes the numbers/digits within a given string from one script to another 'Decimal' representated the stardard numbers 0-9, if a script does not exist an exception will be thrown.

Examples for conversion from Arabic to Latin numerals: convertNumerals('١١٠ Tests', 'Arab'); -> returns '100 Tests' Example for conversion from Latin to Arabic numerals: convertNumerals('100 Tests', 'Latn', 'Arab'); -> returns '١١٠ Tests'

Parameters:
string$inputString to convert
string$fromScript to parse, see Zend_Locale::getScriptList() for details.
string$toOPTIONAL Script to convert to
Returns:
string Returns the converted input
Exceptions:
Zend_Locale_Exception

Definition at line 194 of file Format.php.

static convertPhpToIsoFormat ( format ) [static]

Converts a format string from PHP's date format to ISO format Remember that Zend Date always returns localized string, so a month name which returns the english month in php's date() will return the translated month name with this function... use 'en' as locale if you are in need of the original english names

The conversion has the following restrictions: 'a', 'A' - Meridiem is not explicit upper/lowercase, you have to upper/lowercase the translated value yourself

Parameters:
string$formatFormat string in PHP's date format
Returns:
string Format string in ISO format

Definition at line 755 of file Format.php.

static getDate ( date,
array $  options = array() 
) [static]

Returns an array with the normalized date from an locale date a input of 10.01.2006 without a $locale would return: array ('day' => 10, 'month' => 1, 'year' => 2006) The 'locale' option is only used to convert human readable day and month names to their numeric equivalents. The 'format' option allows specification of self-defined date formats, when not using the default format for the 'locale'.

Parameters:
string$dateDate string
array$optionsOptions: format_type, fix_date, locale, date_format. See setOptions() for details.
Returns:
array Possible array members: day, month, year, hour, minute, second, fixed, format

Definition at line 1109 of file Format.php.

static getDateFormat ( locale = null ) [static]

Returns the default date format for $locale.

Parameters:
string | Zend_Locale$localeOPTIONAL Locale of $number, possibly in string form (e.g. 'de_AT')
Returns:
string format
Exceptions:
Zend_Locale_Exceptionthrows an exception when locale data is broken

Definition at line 1086 of file Format.php.

static getDateTime ( datetime,
array $  options = array() 
) [static]

Returns an array with 'year', 'month', 'day', 'hour', 'minute', and 'second' elements extracted from $datetime according to the order described in $format. For a format of 'd.M.y H:m:s', and an input of 10.05.1985 11:20:55, getDateTime() would return: array ('year' => 1985, 'month' => 5, 'day' => 10, 'hour' => 11, 'minute' => 20, 'second' => 55) The optional $locale parameter may be used to help extract times from strings containing both a time and a day or month name.

Parameters:
string$datetimeDateTime string
array$optionsOptions: format_type, fix_date, locale, date_format. See setOptions() for details.
Returns:
array Possible array members: day, month, year, hour, minute, second, fixed, format

Definition at line 1242 of file Format.php.

static getDateTimeFormat ( locale = null ) [static]

Returns the default datetime format for $locale.

Parameters:
string | Zend_Locale$localeOPTIONAL Locale of $number, possibly in string form (e.g. 'de_AT')
Returns:
string format

Definition at line 1220 of file Format.php.

static getFloat ( input,
array $  options = array() 
) [static]

Alias for getNumber

Parameters:
string$valueNumber to localize
array$optionsOptions: locale, precision. See setOptions() for details.
Returns:
float

Definition at line 655 of file Format.php.

static getInteger ( input,
array $  options = array() 
) [static]

Returns the first found integer from an string Parsing depends on given locale (grouping and decimal)

Examples for input: ' 2345.4356,1234' = 23455456 '+23,3452.123' = 233452 ' 12343 ' = 12343 '-9456km' = -9456 '0' = 0 '(-){0,1}(+(\.){0,1})*(\,){0,1})+'

Parameters:
string$inputInput string to parse for numbers
array$optionsOptions: locale. See setOptions() for details.
Returns:
integer Returns the extracted number

Definition at line 703 of file Format.php.

static getNumber ( input,
array $  options = array() 
) [static]

Returns the normalized number from a localized one Parsing depends on given locale (grouping and decimal)

Examples for input: '2345.4356,1234' = 23455456.1234 '+23,3452.123' = 233452.123 '12343 ' = 12343 '-9456' = -9456 '0' = 0

Parameters:
string$inputInput string to parse for numbers
array$optionsOptions: locale, precision. See setOptions() for details.
Returns:
string Returns the extracted number
Exceptions:
Zend_Locale_Exception

Definition at line 238 of file Format.php.

static getTime ( time,
array $  options = array() 
) [static]

Returns an array with 'hour', 'minute', and 'second' elements extracted from $time according to the order described in $format. For a format of 'H:m:s', and an input of 11:20:55, getTime() would return: array ('hour' => 11, 'minute' => 20, 'second' => 55) The optional $locale parameter may be used to help extract times from strings containing both a time and a day or month name.

Parameters:
string$timeTime string
array$optionsOptions: format_type, fix_date, locale, date_format. See setOptions() for details.
Returns:
array Possible array members: day, month, year, hour, minute, second, fixed, format

Definition at line 1204 of file Format.php.

static getTimeFormat ( locale = null ) [static]

Returns the default time format for $locale.

Parameters:
string | Zend_Locale$localeOPTIONAL Locale of $number, possibly in string form (e.g. 'de_AT')
Returns:
string format

Definition at line 1182 of file Format.php.

static isFloat ( value,
array $  options = array() 
) [static]

Returns if a float was found Alias for isNumber()

Parameters:
string$inputLocalized number string
array$optionsOptions: locale. See setOptions() for details.
Returns:
boolean Returns true if a number was found

Definition at line 682 of file Format.php.

static isInteger ( value,
array $  options = array() 
) [static]

Returns if a integer was found

Parameters:
string$inputLocalized number string
array$optionsOptions: locale. See setOptions() for details.
Returns:
boolean Returns true if a integer was found

Definition at line 730 of file Format.php.

static isNumber ( input,
array $  options = array() 
) [static]

Checks if the input contains a normalized or localized number

Parameters:
string$inputLocalized number string
array$optionsOptions: locale. See setOptions() for details.
Returns:
boolean Returns true if a number was found

Definition at line 499 of file Format.php.

static setOptions ( array $  options = array() ) [static]

Sets class wide options, if no option was given, the actual set options will be returned The 'precision' option of a value is used to truncate or stretch extra digits. -1 means not to touch the extra digits. The 'locale' option helps when parsing numbers and dates using separators and month names. The date format 'format_type' option selects between CLDR/ISO date format specifier tokens and PHP's date() tokens. The 'fix_date' option enables or disables heuristics that attempt to correct invalid dates. The 'number_format' option can be used to specify a default number format string The 'date_format' option can be used to specify a default date format string, but beware of using getDate(), checkDateFormat() and getTime() after using setOptions() with a 'format'. To use these four methods with the default date format for a locale, use array('date_format' => null, 'locale' => $locale) for their options.

Parameters:
array$optionsArray of options, keyed by option name: format_type = 'iso' | 'php', fix_date = true | false, locale = Zend_Locale | locale string, precision = whole number between -1 and 30
Exceptions:
Zend_Locale_Exception
Returns:
Options array if no option was given

Definition at line 64 of file Format.php.

static toFloat ( value,
array $  options = array() 
) [static]

Returns a locale formatted integer number Alias for toNumber()

Parameters:
string$valueNumber to normalize
array$optionsOptions: locale, precision. See setOptions() for details.
Returns:
string Locale formatted number

Definition at line 668 of file Format.php.

static toInteger ( value,
array $  options = array() 
) [static]

Returns a localized number

Parameters:
string$valueNumber to normalize
array$optionsOptions: locale. See setOptions() for details.
Returns:
string Locale formatted number

Definition at line 716 of file Format.php.

static toNumber ( value,
array $  options = array() 
) [static]

Returns a locale formatted number depending on the given options. The seperation and fraction sign is used from the set locale. ##0.# -> 12345.12345 -> 12345.12345 ##0.00 -> 12345.12345 -> 12345.12 ##,##0.00 -> 12345.12345 -> 12,345.12

Parameters:
string$inputLocalized number string
array$optionsOptions: number_format, locale, precision. See setOptions() for details.
Returns:
string locale formatted number
Exceptions:
Zend_Locale_Exception

Definition at line 290 of file Format.php.


The documentation for this class was generated from the following file: