Locale/Format.php
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Locale
- Subpackage
- Format
- Version
- $Id$
\Zend_Locale_Format
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants
Properties

$_options = array('date_format' => null, 'number_format' => null, 'format_type' => 'iso', 'fix_date' => false, 'locale' => null, 'cache' => null, 'disableCache' => false, 'precision' => null)array('date_format' => null, 'number_format' => null, 'format_type' => 'iso', 'fix_date' => false, 'locale' => null, 'cache' => null, 'disableCache' => false, 'precision' => null)Details- Type
- n/a
Methods

_checkOptions(array $options = array()) : \OptionsInternal function for checking the options array of proper input values See {@link setOptions()} for details.
| Name | Type | Description |
|---|---|---|
| $options | array | Array of options, keyed by option name: format_type = 'iso' | 'php', fix_date = true | false, |
| Type | Description |
|---|---|
| \Options | array if no option was given |
| Exception | Description |
|---|---|
| \Zend_Locale_Exception |

_getRegexForType(string $type, $options) : stringInternal method to convert cldr number syntax into regex
| Name | Type | Description |
|---|---|---|
| $type | string | |
| $options |
| Type | Description |
|---|---|
| string |

_getUniCodeSupport() : booleanInternal method to detect of Unicode supports UTF8 which should be enabled within vanilla php installations
| Type | Description |
|---|---|
| boolean |

_parseDate(string $date, array $options) : arrayParse date and split in named array fields
| Name | Type | Description |
|---|---|---|
| $date | string | Date string to parse |
| $options | array | Options: format_type, fix_date, locale, date_format. See {@link setOptions()} for details. |
| Type | Description |
|---|---|
| array | Possible array members: day, month, year, hour, minute, second, fixed, format |

_replaceMonth(string $number, array $monthlist) : int | falseSearch $number for a month name found in $monthlist, and replace if found.
| Name | Type | Description |
|---|---|---|
| $number | string | Date string (modified) |
| $monthlist | array | List of month names |
| Type | Description |
|---|---|
| int | false | Position of replaced string (false if nothing replaced) |

_seperateFormat( $format, $value, $precision) : void| Name | Type | Description |
|---|---|---|
| $format | ||
| $value | ||
| $precision |

checkDateFormat(string $date, array $options = array()) : booleanReturns if the given datestring contains all date parts from the given format.
| Name | Type | Description |
|---|---|---|
| $date | string | Date string |
| $options | array | Options: format_type, fix_date, locale, date_format. See {@link setOptions()} for details. |
| Type | Description |
|---|---|
| boolean |

convertNumerals(string $input, string $from, string $to = null) : stringChanges 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.
| Name | Type | Description |
|---|---|---|
| $input | string | String to convert |
| $from | string | Script to parse, see {@link Zend_Locale::getScriptList()} for details. |
| $to | string | OPTIONAL Script to convert to |
| Type | Description |
|---|---|
| string | Returns the converted input |
| Exception | Description |
|---|---|
| \Zend_Locale_Exception |

convertPhpToIsoFormat(string $format) : stringConverts 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.
| Name | Type | Description |
|---|---|---|
| $format | string | Format string in PHP's date format |
| Type | Description |
|---|---|
| string | Format string in ISO format |

getDate(string $date, array $options = array()) : arrayReturns 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.
| Name | Type | Description |
|---|---|---|
| $date | string | Date string |
| $options | array | Options: format_type, fix_date, locale, date_format. See {@link setOptions()} for details. |
| Type | Description |
|---|---|
| array | Possible array members: day, month, year, hour, minute, second, fixed, format |

getDateFormat(string | \Zend_Locale $locale = null) : stringReturns the default date format for $locale.
| Name | Type | Description |
|---|---|---|
| $locale | string | \Zend_Locale | OPTIONAL Locale of $number, possibly in string form (e.g. 'de_AT') |
| Type | Description |
|---|---|
| string | format |
| Exception | Description |
|---|---|
| \Zend_Locale_Exception | throws an exception when locale data is broken |

getDateTime(string $datetime, array $options = array()) : arrayReturns 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.
| Name | Type | Description |
|---|---|---|
| $datetime | string | DateTime string |
| $options | array | Options: format_type, fix_date, locale, date_format. See {@link setOptions()} for details. |
| Type | Description |
|---|---|
| array | Possible array members: day, month, year, hour, minute, second, fixed, format |

getDateTimeFormat(string | \Zend_Locale $locale = null) : stringReturns the default datetime format for $locale.
| Name | Type | Description |
|---|---|---|
| $locale | string | \Zend_Locale | OPTIONAL Locale of $number, possibly in string form (e.g. 'de_AT') |
| Type | Description |
|---|---|
| string | format |

getFloat( $input, array $options = array()) : floatAlias for getNumber
| Name | Type | Description |
|---|---|---|
| $input | ||
| $options | array | Options: locale, precision. See {@link setOptions()} for details. |
| Type | Description |
|---|---|
| float |

getInteger(string $input, array $options = array()) : integerReturns the first found integer from an string Parsing depends on given locale (grouping and decimal)
| Name | Type | Description |
|---|---|---|
| $input | string | Input string to parse for numbers |
| $options | array | Options: locale. See {@link setOptions()} for details. |
| Type | Description |
|---|---|
| integer | Returns the extracted number |

getNumber(string $input, array $options = array()) : stringReturns the normalized number from a localized one Parsing depends on given locale (grouping and decimal)
| Name | Type | Description |
|---|---|---|
| $input | string | Input string to parse for numbers |
| $options | array | Options: locale, precision. See {@link setOptions()} for details. |
| Type | Description |
|---|---|
| string | Returns the extracted number |
| Exception | Description |
|---|---|
| \Zend_Locale_Exception |

getTime(string $time, array $options = array()) : arrayReturns 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.
| Name | Type | Description |
|---|---|---|
| $time | string | Time string |
| $options | array | Options: format_type, fix_date, locale, date_format. See {@link setOptions()} for details. |
| Type | Description |
|---|---|
| array | Possible array members: day, month, year, hour, minute, second, fixed, format |

getTimeFormat(string | \Zend_Locale $locale = null) : stringReturns the default time format for $locale.
| Name | Type | Description |
|---|---|---|
| $locale | string | \Zend_Locale | OPTIONAL Locale of $number, possibly in string form (e.g. 'de_AT') |
| Type | Description |
|---|---|
| string | format |

isFloat( $value, array $options = array()) : booleanReturns if a float was found Alias for isNumber()
| Name | Type | Description |
|---|---|---|
| $value | ||
| $options | array | Options: locale. See {@link setOptions()} for details. |
| Type | Description |
|---|---|
| boolean | Returns true if a number was found |

isInteger( $value, array $options = array()) : booleanReturns if a integer was found
| Name | Type | Description |
|---|---|---|
| $value | ||
| $options | array | Options: locale. See {@link setOptions()} for details. |
| Type | Description |
|---|---|
| boolean | Returns true if a integer was found |

isNumber(string $input, array $options = array()) : booleanChecks if the input contains a normalized or localized number
| Name | Type | Description |
|---|---|---|
| $input | string | Localized number string |
| $options | array | Options: locale. See {@link setOptions()} for details. |
| Type | Description |
|---|---|
| boolean | Returns true if a number was found |

setOptions(array $options = array()) : \OptionsSets 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.
| Name | Type | Description |
|---|---|---|
| $options | array | Array of options, keyed by option name: format_type = 'iso' | 'php', fix_date = true | false, |
| Type | Description |
|---|---|
| \Options | array if no option was given |
| Exception | Description |
|---|---|
| \Zend_Locale_Exception |

toFloat(string $value, array $options = array()) : stringReturns a locale formatted integer number Alias for toNumber()
| Name | Type | Description |
|---|---|---|
| $value | string | Number to normalize |
| $options | array | Options: locale, precision. See {@link setOptions()} for details. |
| Type | Description |
|---|---|
| string | Locale formatted number |

toInteger(string $value, array $options = array()) : stringReturns a localized number
| Name | Type | Description |
|---|---|---|
| $value | string | Number to normalize |
| $options | array | Options: locale. See {@link setOptions()} for details. |
| Type | Description |
|---|---|
| string | Locale formatted number |

toNumber( $value, array $options = array()) : stringReturns a locale formatted number depending on the given options.
| Name | Type | Description |
|---|---|---|
| $value | ||
| $options | array | Options: number_format, locale, precision. See {@link setOptions()} for details. |
| Type | Description |
|---|---|
| string | locale formatted number |
| Exception | Description |
|---|---|
| \Zend_Locale_Exception |