Page MenuHomePhabricator

Add functionality to let Wikibase Lua code format dates with the calendar model automatically shown if needed.
Open, Needs TriagePublic

Description

When Wikibase formats time values as HTML, it automatically shows the calendar model if needed (depending on the precision, date, and what the automatically guessed calendar model would be for that date). However, formatting times as wikitext or plain text only formats the time value itself. Lua modules can add the calendar model “manually”, but Wikibase’s logic deciding when to show the calendar model or not isn’t accessible to them.

=mw.wikibase.formatValue({snaktype = 'value', property = 'P569', datatype = 'time', datavalue = {type = 'time', value = {time = '+1879-03-14T00:00:00Z', timezone = 0, before = 0, after = 0, precision = 11, calendarmodel = 'http://www.wikidata.org/entity/Q1985727' }}})
<span>14 March 1879</span>
=mw.wikibase.renderSnak({snaktype = 'value', property = 'P569', datatype = 'time', datavalue = {type = 'time', value = {time = '+1879-03-14T00:00:00Z', timezone = 0, before = 0, after = 0, precision = 11, calendarmodel = 'http://www.wikidata.org/entity/Q1985727' }}})
14 March 1879

Event Timeline

Note that since T323568, the plain text and wikitext formatters are capable of adding the calendar model, but don’t do it by default; it can be enabled by setting the showcalendar parser option to 'auto'. But I’m not sure if adding the ability for Lua clients to pass arbitrary parser options into the “format”/“render” methods is the best way to solve this.

(Also, this task probably needs some more polishing in general.)