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', 'Latin', 'Arab'); -> returns '١١٠ Tests'
static string
convertNumerals
(string $input, $from, [string $to = null], string $locale)
-
string
$input: String to convert
-
string
$locale: Script to parse, see Zend_Locale->getScriptList() for details
-
string
$to: OPTIONAL Script to convert to
-
$from
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 optional $locale parameter is only used to convert human readable day and month names to their numeric equivalents. Some forms of invalid dates are automatically fixed, such as a $date string where month and days are swapped, and one of the two is larger than 12, or when a month or larger than 31. However, such dates are often ambiguous, so the "fixed" results might not be truly fixed. If the date was "fixed", then the return array element "fixed" will contain a non-zero value.
static
array
getCorrectableDate
(
string $date, [
string $format =
null], [
string|Zend_Locale $locale =
null])
-
string
$date: Date string
-
string
$format: OPTIONAL Date type CLDR format to parse. Only single-letter codes (H, m, s, y, M, d), and MMMM and EEEE are supported.
-
string|Zend_Locale
$locale: OPTIONAL Locale of $number, possibly in string form (e.g. 'de_AT')
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 optional $locale parameter is only used to convert human readable day and month names to their numeric equivalents.
static
array
getDate
(
string $date, [
string $format =
null], [
string|Zend_Locale $locale =
null])
-
string
$date: Date string
-
string
$format: OPTIONAL Date type CLDR format to parse. Only single-letter codes (H, m, s, y, M, d), and MMMM and EEEE are supported.
-
string|Zend_Locale
$locale: OPTIONAL Locale of $number, possibly in string form (e.g. 'de_AT')
Returns the default date format for $locale.
static
string
getDateFormat
([
string|Zend_Locale $locale =
null])
-
string|Zend_Locale
$locale: OPTIONAL Locale of $number, possibly in string form (e.g. 'de_AT')
Alias for getNumber
static
float
getFloat
(
$input, [
integer $precision =
null], [
string|Zend_Locale $locale =
null],
string $value)
-
string
$value: Number to localize
-
integer
$precision: OPTIONAL Precision of the float value, not touched if null
-
string|Zend_Locale
$locale: OPTIONAL Locale for parsing
-
$input
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}(\d+(\.){0,1})*(\,){0,1})\d+'
static
integer
getInteger
(
string $input, [
string|Zend_Locale $locale =
null])
-
string
$input: Input string to parse for numbers
-
string|Zend_Locale
$locale: OPTIONAL locale for parsing the number format
Returns the first found number from an string Parsing depends on given locale (grouping and decimal)
Examples for input: ' 2345.4356,1234' = 23455456.1234 '+23,3452.123' = 233452.123 ' 12343 ' = 12343 '-9456km' = -9456 '0' = 0 '(-){0,1}(\d+(\.){0,1})*(\,){0,1})\d+' '١١٠ Tests' = 110 call: getNumber($string, 'Arab');
static
integer|string
getNumber
(
string $input, [
integer $precision =
null], [
string|Zend_Locale $locale =
null])
-
string
$input: Input string to parse for numbers
-
integer
$precision: OPTIONAL Precision of a float value, not touched if null
-
string|Zend_Locale
$locale: OPTIONAL Locale for parsing the number format
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.
static
array
getTime
(
string $time, [
string $format =
null], [
string|Zend_Locale $locale =
null])
-
string
$time: Time string
-
string
$format: Date type CLDR format to parse. Only single-letter codes(H, m, s, y, M, d), and MMMM and EEEE are supported.
-
string|Zend_Locale
$locale: OPTIONAL Locale of $number, possibly in string form (e.g. 'de_AT')
Returns the default time format for $locale.
static
string
getTimeFormat
([
string|Zend_Locale $locale =
null])
-
string|Zend_Locale
$locale: OPTIONAL Locale of $number, possibly in string form (e.g. 'de_AT')
Returns if the given string is a date
Some forms of invalid dates are automatically fixed, such as a $date string where month and days are swapped, and one of the two is larger than 12, or when a month or larger than 31. However, such dates are often ambiguous, so the "fixed" results might not be truly fixed.
static
boolean
isCorrectableDate
(
string $date, [
string $format =
null], [
string|Zend_Locale $locale =
null])
-
string
$date: Date string
-
string
$format: Date type CLDR format to parse. Only single-letter codes (H, m, s, y, M, d), and MMMM and EEEE are supported.
-
string|Zend_Locale
$locale: OPTIONAL Locale for parsing the date string
Returns if the given string is a date
static
boolean
isDate
(
string $date, [
string $format =
null], [
string|Zend_Locale $locale =
null])
-
string
$date: Date string
-
string
$format: Date type CLDR format to parse. Only single-letter codes (H, m, s, y, M, d), and MMMM and EEEE are supported.
-
string|Zend_Locale
$locale: OPTIONAL Locale for parsing the date string
Returns if a float was found Alias for isNumber()
static
boolean
isFloat
(
$value, [
string|Zend_Locale $locale =
null],
string $input)
-
string
$input: Localized number string
-
string|Zend_Locale
$locale: OPTIONAL Locale for parsing
-
$value
Returns if a integer was found
static
boolean
isInteger
(
$value, [
string|Zend_Locale $locale =
null],
string $input)
-
string
$input: Localized number string
-
string|Zend_Locale
$locale: OPTIONAL Locale for parsing
-
$value
Checks if the input contains a normalized or localized number
static
boolean
isNumber
(
string $input, [
string|Zend_Locale $locale =
null])
-
string
$input: Localized number string
-
string|Zend_Locale
$locale: OPTIONAL Locale for parsing
Returns is the given string is a time
static boolean
isTime
(string $time, [string $format = null], [locale $locale = null])
-
string
$time: Time string
-
string
$format: Time type CLDR format !!!
-
locale
$locale: OPTIONAL Locale of time string
Returns a locale formatted integer number Alias for toNumber()
static
string
toFloat
(
string $value, [
integer $precision =
null], [
string|Zend_Locale $locale =
null])
-
string
$value: Number to normalize
-
integer
$precision: OPTIONAL Precision of a float value, not touched if null
-
string|Zend_Locale
$locale: OPTIONAL Locale for parsing
Returns a localized number
static
string
toInteger
(
string $value, [
string|Zend_Locale $locale =
null])
-
string
$value: Number to normalize
-
string|Zend_Locale
$locale: OPTIONAL Locale for parsing
Returns a locale formatted number
static
string
toNumber
(
string $value, [
integer $precision =
null], [
string|Zend_Locale $locale =
null])
-
string
$value: Number to localize
-
integer
$precision: OPTIONAL Precision of a float value, not touched if null or 0, -1 erased
-
string|Zend_Locale
$locale: OPTIONAL Locale for parsing
Returns a self formatted number
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
static
string
toNumberFormat
(
string $value, [
integer $format =
null], [
string|Zend_Locale $locale =
null])
-
string
$value: Number to localize
-
integer
$format: OPTIONAL Format to use
-
string|Zend_Locale
$locale: OPTIONAL Locale for parsing