Locale/Format.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework
LICENSE This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
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

Package: Zend_Locale\Format
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

>VConstant  STANDARD = 'auto'

Properties

>VPropertyprivate$_options = array('date_format' => null, 'number_format' => null, 'format_type' => 'iso', 'fix_date' => false, 'locale' => null, 'cache' => null, 'disableCache' => false, 'precision' => null)
static
Default valuearray('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

methodprivate_checkOptions(array $options = array()) : \Options
static

Internal function for checking the options array of proper input values See {@link setOptions()} for details.

Parameters
NameTypeDescription
$optionsarray

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
Returns
TypeDescription
\Optionsarray if no option was given
Throws
ExceptionDescription
\Zend_Locale_Exception
methodprivate_getRegexForType(string $type,  $options) : string
static

Internal method to convert cldr number syntax into regex

Parameters
NameTypeDescription
$typestring
$options
Returns
TypeDescription
string
methodprotected_getUniCodeSupport() : boolean
static

Internal method to detect of Unicode supports UTF8 which should be enabled within vanilla php installations

Returns
TypeDescription
boolean
methodprivate_parseDate(string $date, array $options) : array
static

Parse date and split in named array fields

Parameters
NameTypeDescription
$datestring

Date string to parse

$optionsarray

Options: format_type, fix_date, locale, date_format. See {@link setOptions()} for details.

Returns
TypeDescription
arrayPossible array members: day, month, year, hour, minute, second, fixed, format
methodprotected_replaceMonth(string $number, array $monthlist) : int | false
static

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

Parameters
NameTypeDescription
$numberstring

Date string (modified)

$monthlistarray

List of month names

Returns
TypeDescription
int | falsePosition of replaced string (false if nothing replaced)
methodprivate_seperateFormat( $format,  $value,  $precision) : void
static

Parameters
NameTypeDescription
$format
$value
$precision
methodpubliccheckDateFormat(string $date, array $options = array()) : boolean
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
NameTypeDescription
$datestring

Date string

$optionsarray

Options: format_type, fix_date, locale, date_format. See {@link setOptions()} for details.

Returns
TypeDescription
boolean
methodpublicconvertNumerals(string $input, string $from, string $to = null) : string
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
NameTypeDescription
$inputstring

String to convert

$fromstring

Script to parse, see {@link Zend_Locale::getScriptList()} for details.

$tostring

OPTIONAL Script to convert to

Returns
TypeDescription
stringReturns the converted input
Throws
ExceptionDescription
\Zend_Locale_Exception
methodpublicconvertPhpToIsoFormat(string $format) : string
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
NameTypeDescription
$formatstring

Format string in PHP's date format

Returns
TypeDescription
stringFormat string in ISO format
methodpublicgetDate(string $date, array $options = array()) : 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
NameTypeDescription
$datestring

Date string

$optionsarray

Options: format_type, fix_date, locale, date_format. See {@link setOptions()} for details.

Returns
TypeDescription
arrayPossible array members: day, month, year, hour, minute, second, fixed, format
methodpublicgetDateFormat(string | \Zend_Locale $locale = null) : string
static

Returns the default date format for $locale.

Parameters
NameTypeDescription
$localestring | \Zend_Locale

OPTIONAL Locale of $number, possibly in string form (e.g. 'de_AT')

Returns
TypeDescription
stringformat
Throws
ExceptionDescription
\Zend_Locale_Exceptionthrows an exception when locale data is broken
methodpublicgetDateTime(string $datetime, array $options = array()) : 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
NameTypeDescription
$datetimestring

DateTime string

$optionsarray

Options: format_type, fix_date, locale, date_format. See {@link setOptions()} for details.

Returns
TypeDescription
arrayPossible array members: day, month, year, hour, minute, second, fixed, format
methodpublicgetDateTimeFormat(string | \Zend_Locale $locale = null) : string
static

Returns the default datetime format for $locale.

Parameters
NameTypeDescription
$localestring | \Zend_Locale

OPTIONAL Locale of $number, possibly in string form (e.g. 'de_AT')

Returns
TypeDescription
stringformat
methodpublicgetFloat( $input, array $options = array()) : float
static

Alias for getNumber

Parameters
NameTypeDescription
$input
$optionsarray

Options: locale, precision. See {@link setOptions()} for details.

Returns
TypeDescription
float
methodpublicgetInteger(string $input, array $options = array()) : integer
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}(\d+(\.){0,1})*(\,){0,1})\d+'
Parameters
NameTypeDescription
$inputstring

Input string to parse for numbers

$optionsarray

Options: locale. See {@link setOptions()} for details.

Returns
TypeDescription
integerReturns the extracted number
methodpublicgetNumber(string $input, array $options = array()) : string
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
NameTypeDescription
$inputstring

Input string to parse for numbers

$optionsarray

Options: locale, precision. See {@link setOptions()} for details.

Returns
TypeDescription
stringReturns the extracted number
Throws
ExceptionDescription
\Zend_Locale_Exception
methodpublicgetTime(string $time, array $options = array()) : 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
NameTypeDescription
$timestring

Time string

$optionsarray

Options: format_type, fix_date, locale, date_format. See {@link setOptions()} for details.

Returns
TypeDescription
arrayPossible array members: day, month, year, hour, minute, second, fixed, format
methodpublicgetTimeFormat(string | \Zend_Locale $locale = null) : string
static

Returns the default time format for $locale.

Parameters
NameTypeDescription
$localestring | \Zend_Locale

OPTIONAL Locale of $number, possibly in string form (e.g. 'de_AT')

Returns
TypeDescription
stringformat
methodpublicisFloat( $value, array $options = array()) : boolean
static

Returns if a float was found Alias for isNumber()

Parameters
NameTypeDescription
$value
$optionsarray

Options: locale. See {@link setOptions()} for details.

Returns
TypeDescription
booleanReturns true if a number was found
methodpublicisInteger( $value, array $options = array()) : boolean
static

Returns if a integer was found

Parameters
NameTypeDescription
$value
$optionsarray

Options: locale. See {@link setOptions()} for details.

Returns
TypeDescription
booleanReturns true if a integer was found
methodpublicisNumber(string $input, array $options = array()) : boolean
static

Checks if the input contains a normalized or localized number

Parameters
NameTypeDescription
$inputstring

Localized number string

$optionsarray

Options: locale. See {@link setOptions()} for details.

Returns
TypeDescription
booleanReturns true if a number was found
methodpublicsetOptions(array $options = array()) : \Options
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
NameTypeDescription
$optionsarray

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
Returns
TypeDescription
\Optionsarray if no option was given
Throws
ExceptionDescription
\Zend_Locale_Exception
methodpublictoFloat(string $value, array $options = array()) : string
static

Returns a locale formatted integer number Alias for toNumber()

Parameters
NameTypeDescription
$valuestring

Number to normalize

$optionsarray

Options: locale, precision. See {@link setOptions()} for details.

Returns
TypeDescription
stringLocale formatted number
methodpublictoInteger(string $value, array $options = array()) : string
static

Returns a localized number

Parameters
NameTypeDescription
$valuestring

Number to normalize

$optionsarray

Options: locale. See {@link setOptions()} for details.

Returns
TypeDescription
stringLocale formatted number
methodpublictoNumber( $value, array $options = array()) : string
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
NameTypeDescription
$value
$optionsarray

Options: number_format, locale, precision. See {@link setOptions()} for details.

Returns
TypeDescription
stringlocale formatted number
Throws
ExceptionDescription
\Zend_Locale_Exception
Documentation was generated by phpDocumentor 2.2.0 .