ICanBoogie/CLDR v1.7.0
  • Namespace
  • Class

Namespaces

  • ICanBoogie
    • CLDR
      • Plurals

Classes

  • AbstractCollection
  • AbstractSectionCollection
  • Calendar
  • CalendarCollection
  • ContextTransforms
  • Currency
  • CurrencyCollection
  • CurrencyFormatter
  • DateFormatter
  • DateTimeAccessor
  • DateTimeFormatter
  • FileProvider
  • ListFormatter
  • Locale
  • LocaleCollection
  • LocalizedCurrency
  • LocalizedDateTime
  • LocalizedListFormatter
  • LocalizedLocale
  • LocalizedNumberFormatter
  • LocalizedObject
  • LocalizedObjectWithFormatter
  • LocalizedTerritory
  • Number
  • NumberFormatter
  • NumberPattern
  • NumberPatternParser
  • Numbers
  • Plurals
  • ProviderCollection
  • RedisProvider
  • Repository
  • RunTimeProvider
  • Supplemental
  • Territory
  • TerritoryCollection
  • TimeFormatter
  • WebProvider

Interfaces

  • Exception
  • Formatter
  • LocalizeAwareInterface
  • Provider

Traits

  • CodePropertyTrait
  • CollectionTrait
  • LocalePropertyTrait
  • LocalizeTrait
  • ProviderStorageBinding
  • RepositoryPropertyTrait

Exceptions

  • ResourceNotFound
  • TerritoryNotDefined

Class DateTimeFormatter

Provides date and time localization.

The class allows you to format dates and times in a locale-sensitive manner using Unicode format patterns.

ICanBoogie\CLDR\DateTimeFormatter implements ICanBoogie\CLDR\Formatter uses ICanBoogie\Accessor\AccessorTrait (not available)

Direct known subclasses

ICanBoogie\CLDR\DateFormatter, ICanBoogie\CLDR\TimeFormatter

Namespace: ICanBoogie\CLDR
Located at DateTimeFormatter.php

Methods summary

protected static array
# tokenize( string $pattern )

Parses the datetime format pattern.

Parses the datetime format pattern.

Parameters

$pattern
The pattern to be parsed.

Returns

array
Tokenized parsing result.
protected ICanBoogie\CLDR\Calendar
# get_calendar( )

Returns

ICanBoogie\CLDR\Calendar
public
# __construct( ICanBoogie\CLDR\Calendar $calendar )

Initializes the ICanBoogie\CLDR\DateTimeFormatter::$calendar property.

Initializes the ICanBoogie\CLDR\DateTimeFormatter::$calendar property.

Parameters

$calendar
public string
# __invoke( mixed $datetime, string $pattern_or_width_or_skeleton )

Alias to the ICanBoogie\CLDR\DateTimeFormatter::format() method.

Alias to the ICanBoogie\CLDR\DateTimeFormatter::format() method.

Parameters

$datetime
$pattern_or_width_or_skeleton

Returns

string
public string
# format( DateTimeInterface|string|integer $datetime, string $pattern_or_width_or_skeleton )

Formats a date according to a pattern.

Formats a date according to a pattern.

Parameters

$datetime
The datetime to format.
$pattern_or_width_or_skeleton

The datetime can be formatted using a pattern, a width (WIDTH_*) or a skeleton. To format the datetime using a so-called "skeleton", the skeleton identifier must be prefixed with the colon sign ":" e.g. ":Ehm". The skeleton identifies the patterns defined under availableFormats.

Returns

string
The formatted date time.

See

http://www.unicode.org/reports/tr35/#Date_Format_Patterns
protected string
# resolve_pattern( string $pattern_or_width_or_skeleton )

Resolves the specified pattern, which can be a width, a skeleton or an actual pattern.

Resolves the specified pattern, which can be a width, a skeleton or an actual pattern.

Parameters

$pattern_or_width_or_skeleton

Returns

string
protected string
# resolve_width( string $pattern_or_width_or_skeleton, string $from )

Resolves widths (full, long, medium, short) into a pattern.

Resolves widths (full, long, medium, short) into a pattern.

Parameters

$pattern_or_width_or_skeleton
$from
Width Source e.g. "timeFormats".

Returns

string
protected string
# format_era( ICanBoogie\CLDR\DateTimeAccessor $datetime, integer $length )

Era - Replaced with the Era string for the current date. One to three letters for the abbreviated form, four letters for the long form, five for the narrow form. [1..3,4,5]

Era - Replaced with the Era string for the current date. One to three letters for the abbreviated form, four letters for the long form, five for the narrow form. [1..3,4,5]

Parameters

$datetime
$length
Number of repetition.

Returns

string
era
protected string
# format_year( ICanBoogie\CLDR\DateTimeAccessor $datetime, integer $length )

Year. Normally the length specifies the padding, but for two letters it also specifies the maximum length. [1..n]

Year. Normally the length specifies the padding, but for two letters it also specifies the maximum length. [1..n]

Parameters

$datetime
$length
Number of repetition.

Returns

string
formatted year
protected string
# format_standalone_quarter( ICanBoogie\CLDR\DateTimeAccessor $datetime, integer $length )

Stand-Alone Quarter - Use one or two "q" for the numerical quarter, three for the abbreviation, or four for the full (wide) name. [1..2,3,4]

Stand-Alone Quarter - Use one or two "q" for the numerical quarter, three for the abbreviation, or four for the full (wide) name. [1..2,3,4]

Parameters

$datetime
Datetime.
$length
Number of repetition.

Returns

string
protected string
# format_standalone_month( ICanBoogie\CLDR\DateTimeAccessor $datetime, integer $length )

Stand-Alone Month - Use one or two "L" for the numerical month, three for the abbreviation, or four for the full (wide) name, or 5 for the narrow name. [1..2,3,4,5]

Stand-Alone Month - Use one or two "L" for the numerical month, three for the abbreviation, or four for the full (wide) name, or 5 for the narrow name. [1..2,3,4,5]

Parameters

$datetime
$length
Number of repetition.

Returns

string
protected string
# format_week_of_year( ICanBoogie\CLDR\DateTimeAccessor $datetime, integer $length )

Week of Year. [1..2]

Week of Year. [1..2]

Parameters

$datetime
$length
Number of repetition.

Returns

string
protected integer|false
# format_week_of_month( ICanBoogie\CLDR\DateTimeAccessor $datetime, integer $length )

Week of Month. [1]

Week of Month. [1]

Parameters

$datetime
$length
Number of repetition.

Returns

integer|false
Week of month, of false if $length is greater than 1.
protected string
# format_day_of_month( ICanBoogie\CLDR\DateTimeAccessor $datetime, integer $length )

Date - Day of the month. [1..2]

Date - Day of the month. [1..2]

Parameters

$datetime
$length
Number of repetition.

Returns

string
protected string
# format_day_of_year( ICanBoogie\CLDR\DateTimeAccessor $datetime, integer $length )

Day of year. [1..3]

Day of year. [1..3]

Parameters

$datetime
$length
Number of repetition.

Returns

string
protected string
# format_day_of_week_in_month( ICanBoogie\CLDR\DateTimeAccessor $datetime, integer $length )

Day of Week in Month. The example is for the 2nd Wed in July. [1]

Day of Week in Month. The example is for the 2nd Wed in July. [1]

Parameters

$datetime
$length
Number of repetition.

Returns

string
protected string
# format_day_in_week( ICanBoogie\CLDR\DateTimeAccessor $datetime, integer $length )

Day of week - Use one through three letters for the short day, or four for the full name, five for the narrow name, or six for the short name. [1..3,4,5,6]

Day of week - Use one through three letters for the short day, or four for the full name, five for the narrow name, or six for the short name. [1..3,4,5,6]

Parameters

$datetime
$length

Returns

string
protected string
# format_day_in_week_stand_alone( ICanBoogie\CLDR\DateTimeAccessor $datetime, integer $length )

Stand-Alone local day of week - Use one letter for the local numeric value (same as 'e'), three for the abbreviated day name, four for the full (wide) name, five for the narrow name, or six for the short name.

Stand-Alone local day of week - Use one letter for the local numeric value (same as 'e'), three for the abbreviated day name, four for the full (wide) name, five for the narrow name, or six for the short name.

Parameters

$datetime
$length

Returns

string
protected string
# format_day_in_week_local( ICanBoogie\CLDR\DateTimeAccessor $datetime, integer $length )

Local day of week. Same as E except adds a numeric value that will depend on the local starting day of the week, using one or two letters. For this example, Monday is the first day of the week.

Local day of week. Same as E except adds a numeric value that will depend on the local starting day of the week, using one or two letters. For this example, Monday is the first day of the week.

Parameters

$datetime
$length

Returns

string
protected string
# format_period( ICanBoogie\CLDR\DateTimeAccessor $datetime )

AM or PM. [1]

AM or PM. [1]

Parameters

$datetime

Returns

string
AM or PM designator
protected string
# format_hour12( ICanBoogie\CLDR\DateTimeAccessor $datetime, integer $length )

Hour [1-12]. When used in skeleton data or in a skeleton passed in an API for flexible data pattern generation, it should match the 12-hour-cycle format preferred by the locale (h or K); it should not match a 24-hour-cycle format (H or k). Use hh for zero padding. [1..2]

Hour [1-12]. When used in skeleton data or in a skeleton passed in an API for flexible data pattern generation, it should match the 12-hour-cycle format preferred by the locale (h or K); it should not match a 24-hour-cycle format (H or k). Use hh for zero padding. [1..2]

Parameters

$datetime
$length
Number of repetition.

Returns

string
protected string
# format_hour24( ICanBoogie\CLDR\DateTimeAccessor $datetime, integer $length )

Hour [0-23]. When used in skeleton data or in a skeleton passed in an API for flexible data pattern generation, it should match the 24-hour-cycle format preferred by the locale (H or k); it should not match a 12-hour-cycle format (h or K). Use HH for zero padding. [1..2]

Hour [0-23]. When used in skeleton data or in a skeleton passed in an API for flexible data pattern generation, it should match the 24-hour-cycle format preferred by the locale (H or k); it should not match a 12-hour-cycle format (h or K). Use HH for zero padding. [1..2]

Parameters

$datetime
$length
Number of repetition.

Returns

string
protected integer
# format_hour_in_period( ICanBoogie\CLDR\DateTimeAccessor $datetime, integer $length )

Hour [0-11]. When used in a skeleton, only matches K or h, see above. Use KK for zero padding. [1..2]

Hour [0-11]. When used in a skeleton, only matches K or h, see above. Use KK for zero padding. [1..2]

Parameters

$datetime
$length
Number of repetition.

Returns

integer
hours in AM/PM format.
protected integer
# format_hour_in_day( ICanBoogie\CLDR\DateTimeAccessor $datetime, integer $length )

Hour [1-24]. When used in a skeleton, only matches k or H, see above. Use kk for zero padding. [1..2]

Hour [1-24]. When used in a skeleton, only matches k or H, see above. Use kk for zero padding. [1..2]

Parameters

$datetime
$length
Number of repetition.

Returns

integer
protected string
# format_minutes( ICanBoogie\CLDR\DateTimeAccessor $datetime, integer $length )

Minute. Use one or two "m" for zero padding.

Minute. Use one or two "m" for zero padding.

Parameters

$datetime
$length
Number of repetition

Returns

string
minutes.
protected string
# format_seconds( ICanBoogie\CLDR\DateTimeAccessor $datetime, integer $length )

Second. Use one or two "s" for zero padding.

Second. Use one or two "s" for zero padding.

Parameters

$datetime
$length
Number of repetition.

Returns

string
seconds
protected string
# format_timezone_basic( ICanBoogie\CLDR\DateTimeAccessor $datetime )

The ISO8601 basic format.

The ISO8601 basic format.

Parameters

$datetime

Returns

string
protected string
# format_timezone_non_location( ICanBoogie\CLDR\DateTimeAccessor $datetime )

The specific non-location format.

The specific non-location format.

Parameters

$datetime

Returns

string

Constants summary

string WIDTH_FULL
# 'full'
string WIDTH_LONG
# 'long'
string WIDTH_MEDIUM
# 'medium'
string WIDTH_SHORT
# 'short'

Properties summary

protected static array $formatters

Pattern characters mapping to the corresponding translator methods.

Pattern characters mapping to the corresponding translator methods.

# [ 'G' => 'format_era', 'y' => 'format_year', // 'Y' => Year (in "Week of Year" based calendars). // 'u' => Extended year. 'Q' => 'format_quarter', 'q' => 'format_standalone_quarter', 'M' => 'format_month', 'L' => 'format_standalone_month', // 'l' => Special symbol for Chinese leap month, used in combination with M. Only used with the Chinese calendar. 'w' => 'format_week_of_year', 'W' => 'format_week_of_month', 'd' => 'format_day_of_month', 'D' => 'format_day_of_year', 'F' => 'format_day_of_week_in_month', 'h' => 'format_hour12', 'H' => 'format_hour24', 'm' => 'format_minutes', 's' => 'format_seconds', 'E' => 'format_day_in_week', 'c' => 'format_day_in_week_stand_alone', 'e' => 'format_day_in_week_local', 'a' => 'format_period', 'k' => 'format_hour_in_day', 'K' => 'format_hour_in_period', 'z' => 'format_timezone_non_location', 'Z' => 'format_timezone_basic', 'v' => 'format_timezone_non_location' ]
protected ICanBoogie\CLDR\Calendar $calendar

The calendar used to format the datetime.

The calendar used to format the datetime.

#

Magic properties

public read-only ICanBoogie\CLDR\Calendar $calendar

The calendar used by the formatter.

ICanBoogie/CLDR v1.7.0 API documentation generated by ApiGen