DatesReader
class DatesReader (View source)
A reader for data placed in "dates" tag in CLDR.
This is not full implementation of features from CLDR. These are missing:
- support for other calendars than Gregorian
- some data from "dates" tag is not used (fields, timeZoneNames)
Constants
FORMAT_TYPE_DATE |
Constant for date-only format |
FORMAT_TYPE_TIME |
Constant for time-only format |
FORMAT_TYPE_DATETIME |
Constant for date and time format |
FORMAT_LENGTH_DEFAULT |
Constant for default length |
FORMAT_LENGTH_FULL |
Constant for full length |
FORMAT_LENGTH_LONG |
Constant for long length |
FORMAT_LENGTH_MEDIUM |
Constant for medium length |
FORMAT_LENGTH_SHORT |
Constant for short length |
Properties
protected CldrRepository | $cldrRepository | ||
protected VariableFrontend | $cache | ||
static protected array | $maxLengthOfSubformats | Static array of date / time formatters supported by this class, and maximal lengths particular formats can get. |
|
protected array | $parsedFormats | An array of parsed formats, indexed by format strings. |
|
protected array | $parsedFormatsIndices | An array which stores references to formats used by particular locales. |
|
protected array | $localizedLiterals | Associative array of literals used in particular locales. |
Methods
Constructs the reader, loading parsed data from cache if available.
Shutdowns the object, saving parsed format strings to the cache.
Returns parsed date or time format basing on locale and desired format length.
Returns parsed date or time format string provided as parameter.
Validates provided format type and throws exception if value is not allowed.
Validates provided format length and throws exception if value is not allowed.
Parses a date / time format (with syntax defined in CLDR).
Parses one CLDR child of "dates" node and returns it's array representation.
Parses "eras" child of "dates" node and returns it's array representation.
Creates one parsed datetime format from date and time formats merged together.
Details
void
injectCldrRepository(CldrRepository $repository)
No description
void
injectCache(VariableFrontend $cache)
Injects the Flow_I18n_Cldr_Reader_DatesReader cache
void
initializeObject()
Constructs the reader, loading parsed data from cache if available.
void
shutdownObject()
Shutdowns the object, saving parsed format strings to the cache.
array
parseFormatFromCldr(Locale $locale, string $formatType, string $formatLength)
Returns parsed date or time format basing on locale and desired format length.
When third parameter ($formatLength) equals 'default', default format for a locale will be used.
array
parseCustomFormat(string $format)
Returns parsed date or time format string provided as parameter.
array
getLocalizedLiteralsForLocale(Locale $locale)
Returns literals array for locale provided.
If array was not generated earlier, it will be generated and cached.
static void
validateFormatType(string $formatType)
Validates provided format type and throws exception if value is not allowed.
static void
validateFormatLength(string $formatLength)
Validates provided format length and throws exception if value is not allowed.
protected array
parseFormat(string $format)
Parses a date / time format (with syntax defined in CLDR).
Not all features from CLDR specification are implemented. Please see the documentation for this class for details what is missing.
protected array
parseLocalizedLiterals(CldrModel $model, string $literalType)
Parses one CLDR child of "dates" node and returns it's array representation.
Many children of "dates" node have common structure, so one method can be used to parse them all.
protected array
parseLocalizedEras(CldrModel $model)
Parses "eras" child of "dates" node and returns it's array representation.
protected array
prepareDateAndTimeFormat(string $format, Locale $locale, string $formatLength)
Creates one parsed datetime format from date and time formats merged together.
The dateTime format from CLDR looks like "{0} {1}" and denotes where to place time and date, and what literals should be placed before, between and / or after them.