Wikibase
MediaWiki Wikibase extension
Wikibase\Lib\Formatters\HtmlTimeFormatter Class Reference

A value formatter that creates a basic, single-line HTML representation of a TimeValue's date, time and calendar model. More...

+ Inheritance diagram for Wikibase\Lib\Formatters\HtmlTimeFormatter:
+ Collaboration diagram for Wikibase\Lib\Formatters\HtmlTimeFormatter:

Public Member Functions

 __construct (?FormatterOptions $options, ValueFormatter $dateTimeFormatter)
 
 format ( $value)
 

Private Member Functions

 calendarNameNeeded (TimeValue $value)
 
 getDefaultCalendar ( $year)
 This guesses the most likely calendar model based on the given TimeValue, ignoring the calendar given in the TimeValue. More...
 
 formatCalendarName ( $calendarModel)
 

Private Attributes

const CALENDAR_KEYS
 
 $dateTimeFormatter
 

Detailed Description

A value formatter that creates a basic, single-line HTML representation of a TimeValue's date, time and calendar model.

The calendar model is added in superscript when needed, either because it's not obvious (e.g. a date in 1800 could be Julian or Gregorian) or because it's different from what the parsers would detect (where 1582 and before is Julian, and 1583 and later is Gregorian).

See also
\Wikibase\Lib\Formatters\TimeDetailsFormatter
Author
Adrian Heine adria.nosp@m.n.he.nosp@m.ine@w.nosp@m.ikim.nosp@m.edia..nosp@m.de
Thiemo Kreuz
Daniel Kinzler

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Lib\Formatters\HtmlTimeFormatter::__construct ( ?FormatterOptions  $options,
ValueFormatter  $dateTimeFormatter 
)
Parameters
FormatterOptions | null$options
ValueFormatter$dateTimeFormatterA value formatter that accepts TimeValue objects and returns the formatted date and time, but not the calendar model. Must return HTML.

Member Function Documentation

◆ calendarNameNeeded()

Wikibase\Lib\Formatters\HtmlTimeFormatter::calendarNameNeeded ( TimeValue  $value)
private
Parameters
TimeValue$value
Returns
bool

◆ format()

Wikibase\Lib\Formatters\HtmlTimeFormatter::format (   $value)
See also
ValueFormatter::format
Parameters
TimeValue$value
Exceptions
InvalidArgumentException
Returns
string HTML

◆ formatCalendarName()

Wikibase\Lib\Formatters\HtmlTimeFormatter::formatCalendarName (   $calendarModel)
private
Parameters
string$calendarModel
Returns
string HTML

◆ getDefaultCalendar()

Wikibase\Lib\Formatters\HtmlTimeFormatter::getDefaultCalendar (   $year)
private

This guesses the most likely calendar model based on the given TimeValue, ignoring the calendar given in the TimeValue.

This should always implement the exact same heuristic as IsoTimestampParser::getCalendarModel().

See also
IsoTimestampParser::getCalendarModel()
Parameters
int$year
Returns
string Calendar URI

Member Data Documentation

◆ $dateTimeFormatter

Wikibase\Lib\Formatters\HtmlTimeFormatter::$dateTimeFormatter
private

◆ CALENDAR_KEYS

const Wikibase\Lib\Formatters\HtmlTimeFormatter::CALENDAR_KEYS
private
Initial value:
= [
TimeValue::CALENDAR_GREGORIAN => 'wikibase-time-calendar-gregorian',
TimeValue::CALENDAR_JULIAN => 'wikibase-time-calendar-julian',
]

The documentation for this class was generated from the following file: