Class Zend_Locale_Format

Description
  • copyright: Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  • license: New BSD License

Located in /Locale/Format.php (line 35)


	
			
Class Constant Summary
 STANDARD = 'auto'
Method Summary
 static boolean checkDateFormat (string $date, [ $options = array()])
 static string convertNumerals (string $input, string $from, [string $to = null])
 static string convertPhpToIsoFormat (string $format)
 static array getDate (string $date, [ $options = array()])
 static string getDateFormat ([string|Zend_Locale $locale = null])
 static array getDateTime (string $datetime, [ $options = array()])
 static string getDateTimeFormat ([string|Zend_Locale $locale = null])
 static float getFloat ( $input, [ $options = array()], string $value)
 static integer getInteger (string $input, [ $options = array()])
 static string getNumber (string $input, [ $options = array()])
 static array getTime (string $time, [ $options = array()])
 static string getTimeFormat ([string|Zend_Locale $locale = null])
 static boolean isFloat ( $value, [ $options = array()], string $input)
 static boolean isInteger ( $value, [ $options = array()], string $input)
 static boolean isNumber (string $input, [ $options = array()])
 static Options setOptions ([ $options = array()])
 static string toFloat (string $value, [ $options = array()])
 static string toInteger (string $value, [ $options = array()])
 static string toNumber ( $value, [ $options = array()], string $input)
 static int|false _replaceMonth ( &$number, array $monthlist, string $number)
Methods
static checkDateFormat (line 1118)

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()

  • access: public
static boolean checkDateFormat (string $date, [ $options = array()])
  • string $date: Date string
  • array $options: Options: format_type, fix_date, locale, date_format. See setOptions() for details.
static convertNumerals (line 194)

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'

  • return: Returns the converted input
  • throws: Zend_Locale_Exception
  • access: public
static string convertNumerals (string $input, string $from, [string $to = null])
  • string $input: String to convert
  • string $from: Script to parse, see Zend_Locale::getScriptList() for details.
  • string $to: OPTIONAL Script to convert to
static convertPhpToIsoFormat (line 728)

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

  • return: Format string in ISO format
  • access: public
static string convertPhpToIsoFormat (string $format)
  • string $format: Format string in PHP's date format
static getDate (line 1098)

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'.

  • return: Possible array members: day, month, year, hour, minute, second, fixed, format
  • access: public
static array getDate (string $date, [ $options = array()])
  • string $date: Date string
  • array $options: Options: format_type, fix_date, locale, date_format. See setOptions() for details.
static getDateFormat (line 1074)

Returns the default date format for $locale.

  • return: format
  • throws: Zend_Locale_Exception throws an exception when locale data is broken
  • access: public
static string getDateFormat ([string|Zend_Locale $locale = null])
  • string|Zend_Locale $locale: OPTIONAL Locale of $number, possibly in string form (e.g. 'de_AT')
static getDateTime (line 1232)

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.

  • return: Possible array members: day, month, year, hour, minute, second, fixed, format
  • access: public
static array getDateTime (string $datetime, [ $options = array()])
  • string $datetime: DateTime string
  • array $options: Options: format_type, fix_date, locale, date_format. See setOptions() for details.
static getDateTimeFormat (line 1210)

Returns the default datetime format for $locale.

  • return: format
  • access: public
static string getDateTimeFormat ([string|Zend_Locale $locale = null])
  • string|Zend_Locale $locale: OPTIONAL Locale of $number, possibly in string form (e.g. 'de_AT')
static getFloat (line 628)

Alias for getNumber

  • access: public
static float getFloat ( $input, [ $options = array()], string $value)
  • string $value: Number to localize
  • array $options: Options: locale, precision. See setOptions() for details.
  • $input
static getInteger (line 676)

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+'

  • return: Returns the extracted number
  • access: public
static integer getInteger (string $input, [ $options = array()])
  • string $input: Input string to parse for numbers
  • array $options: Options: locale. See setOptions() for details.
static getNumber (line 238)

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

  • return: Returns the extracted number
  • throws: Zend_Locale_Exception
  • access: public
static string getNumber (string $input, [ $options = array()])
  • string $input: Input string to parse for numbers
  • array $options: Options: locale, precision. See setOptions() for details.
static getTime (line 1194)

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.

  • return: Possible array members: day, month, year, hour, minute, second, fixed, format
  • access: public
static array getTime (string $time, [ $options = array()])
  • string $time: Time string
  • array $options: Options: format_type, fix_date, locale, date_format. See setOptions() for details.
static getTimeFormat (line 1172)

Returns the default time format for $locale.

  • return: format
  • access: public
static string getTimeFormat ([string|Zend_Locale $locale = null])
  • string|Zend_Locale $locale: OPTIONAL Locale of $number, possibly in string form (e.g. 'de_AT')
static isFloat (line 655)

Returns if a float was found Alias for isNumber()

  • return: Returns true if a number was found
  • access: public
static boolean isFloat ( $value, [ $options = array()], string $input)
  • string $input: Localized number string
  • array $options: Options: locale. See setOptions() for details.
  • $value
static isInteger (line 703)

Returns if a integer was found

  • return: Returns true if a integer was found
  • access: public
static boolean isInteger ( $value, [ $options = array()], string $input)
  • string $input: Localized number string
  • array $options: Options: locale. See setOptions() for details.
  • $value
static isNumber (line 498)

Checks if the input contains a normalized or localized number

  • return: Returns true if a number was found
  • access: public
static boolean isNumber (string $input, [ $options = array()])
  • string $input: Localized number string
  • array $options: Options: locale. See setOptions() for details.
static setOptions (line 64)

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.

  • return: array if no option was given
  • throws: Zend_Locale_Exception
  • access: public
static Options setOptions ([ $options = array()])
  • array $options: Array 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
static toFloat (line 641)

Returns a locale formatted integer number Alias for toNumber()

  • return: Locale formatted number
  • access: public
static string toFloat (string $value, [ $options = array()])
  • string $value: Number to normalize
  • array $options: Options: locale, precision. See setOptions() for details.
static toInteger (line 689)

Returns a localized number

  • return: Locale formatted number
  • access: public
static string toInteger (string $value, [ $options = array()])
  • string $value: Number to normalize
  • array $options: Options: locale. See setOptions() for details.
static toNumber (line 294)

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

  • return: locale formatted number
  • throws: Zend_Locale_Exception
  • access: public
static string toNumber ( $value, [ $options = array()], string $input)
  • string $input: Localized number string
  • array $options: Options: number_format, locale, precision. See setOptions() for details.
  • $value
static _replaceMonth (line 1048)

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

  • return: Position of replaced string (false if nothing replaced)
  • access: protected
static int|false _replaceMonth ( &$number, array $monthlist, string $number)
  • string $number: Date string (modified)
  • array $monthlist: List of month names
  • &$number
Class Constants
STANDARD = 'auto' (line 37)

Documentation generated on Mon, 21 Jun 2010 15:24:34 -0400 by phpDocumentor 1.4.3