Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Lib\Formatters\ShowCalendarModelDecider Class Reference

A helper class for time value formatters, deciding whether the calendar model should be shown or not. More...

Public Member Functions

 showCalendarModel (TimeValue $value, FormatterOptions $options)
 Decide whether the calendar model should be shown or not.
 

Public Attributes

const OPT_SHOW_CALENDAR = 'showcalendar'
 A formatter option that determines whether the calendar model will be shown or not.
 

Private Member Functions

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

Detailed Description

A helper class for time value formatters, deciding whether the calendar model should be shown or not.

When the 'showcalendar' formatter option is set to 'auto', the calendar model is shown if it's not obvious (e.g. a date in 1800 could be Julian or Gregorian) or if it's different from what the parsers would detect (where 1582 and before is Julian, and 1583 and later is Gregorian).

Member Function Documentation

◆ calendarNameNeeded()

Wikibase\Lib\Formatters\ShowCalendarModelDecider::calendarNameNeeded ( TimeValue  $value)
private

◆ getDefaultCalendar()

Wikibase\Lib\Formatters\ShowCalendarModelDecider::getDefaultCalendar ( int  $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

◆ showCalendarModel()

Wikibase\Lib\Formatters\ShowCalendarModelDecider::showCalendarModel ( TimeValue  $value,
FormatterOptions  $options 
)

Decide whether the calendar model should be shown or not.

Parameters
TimeValue$valueThe time value to which the decision applies.
FormatterOptions$optionsThe formatter options. The caller must have set a default for ShowCalendarModelDecider::OPT_SHOW_CALENDAR.
Returns
bool

Member Data Documentation

◆ OPT_SHOW_CALENDAR

const Wikibase\Lib\Formatters\ShowCalendarModelDecider::OPT_SHOW_CALENDAR = 'showcalendar'

A formatter option that determines whether the calendar model will be shown or not.

If true or false, always show or don’t show the calendar model; if 'auto', show the calendar model if it is needed.


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