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
Methods summary
public
__construct( ICanBoogie\CLDR\Calendar
$calendar
)
Initializes the ICanBoogie\CLDR\DateTimeFormatter::$calendar
property.
public
__invoke( mixed $datetime
, string $pattern_or_width_or_skeleton
)
: string
Alias to the ICanBoogie\CLDR\DateTimeFormatter::format()
method.
public
format( DateTimeInterface|string|integer $datetime
, string $pattern_or_width_or_skeleton
)
: string
Formats a date according to a pattern.
protected
resolve_pattern( string $pattern_or_width_or_skeleton
)
: string
Resolves the specified pattern, which can be a width, a skeleton or an actual pattern.
protected
resolve_width( string $pattern_or_width_or_skeleton
, string $from
)
: string
Resolves widths (full, long, medium, short) into a pattern.
protected
format_era( ICanBoogie\CLDR\DateTimeAccessor
$datetime
, integer $length
)
: string
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]
protected
format_year( ICanBoogie\CLDR\DateTimeAccessor
$datetime
, integer $length
)
: string
Year. Normally the length specifies the padding, but for two letters it also specifies the maximum length. [1..n]
protected
format_standalone_quarter( ICanBoogie\CLDR\DateTimeAccessor
$datetime
, integer $length
)
: string
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]
protected
format_standalone_month( ICanBoogie\CLDR\DateTimeAccessor
$datetime
, integer $length
)
: string
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]
protected
format_week_of_year( ICanBoogie\CLDR\DateTimeAccessor
$datetime
, integer $length
)
: string
Week of Year. [1..2]
protected
format_week_of_month( ICanBoogie\CLDR\DateTimeAccessor
$datetime
, integer $length
)
: integer|false
Week of Month. [1]
protected
format_day_of_month( ICanBoogie\CLDR\DateTimeAccessor
$datetime
, integer $length
)
: string
Date - Day of the month. [1..2]
protected
format_day_of_year( ICanBoogie\CLDR\DateTimeAccessor
$datetime
, integer $length
)
: string
Day of year. [1..3]
protected
format_day_of_week_in_month( ICanBoogie\CLDR\DateTimeAccessor
$datetime
, integer $length
)
: string
Day of Week in Month. The example is for the 2nd Wed in July. [1]
protected
format_day_in_week( ICanBoogie\CLDR\DateTimeAccessor
$datetime
, integer $length
)
: string
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]
protected
format_day_in_week_stand_alone( ICanBoogie\CLDR\DateTimeAccessor
$datetime
, integer $length
)
: string
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.
protected
format_day_in_week_local( ICanBoogie\CLDR\DateTimeAccessor
$datetime
, integer $length
)
: string
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.
protected
format_hour12( ICanBoogie\CLDR\DateTimeAccessor
$datetime
, integer $length
)
: string
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]
protected
format_hour24( ICanBoogie\CLDR\DateTimeAccessor
$datetime
, integer $length
)
: string
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]
protected
format_hour_in_period( ICanBoogie\CLDR\DateTimeAccessor
$datetime
, integer $length
)
: integer
Hour [0-11]. When used in a skeleton, only matches K or h, see above. Use KK for zero padding. [1..2]
protected
format_hour_in_day( ICanBoogie\CLDR\DateTimeAccessor
$datetime
, integer $length
)
: integer
Hour [1-24]. When used in a skeleton, only matches k or H, see above. Use kk for zero padding. [1..2]
protected
format_minutes( ICanBoogie\CLDR\DateTimeAccessor
$datetime
, integer $length
)
: string
Minute. Use one or two "m" for zero padding.
protected
format_seconds( ICanBoogie\CLDR\DateTimeAccessor
$datetime
, integer $length
)
: string
Second. Use one or two "s" for zero padding.
protected
format_timezone_basic( ICanBoogie\CLDR\DateTimeAccessor
$datetime
)
: string
The ISO8601 basic format.
protected
format_timezone_non_location( ICanBoogie\CLDR\DateTimeAccessor
$datetime
)
: string
The specific non-location format.
Constants summary
Properties summary
protected static
$formatters
: array
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' ]