Template:Date precision/doc

This template develops the  function from Module:WikidataIB for use in comparisons.

The  function takes a property-ID (as the first unnamed parameter) and an entity-ID (as qid) and returns the precision of the first best date value for the given property of the given entity. If the entity-ID is not given, the entity-ID connected to the current page is used.

The precisions are an integer from 0 to 11, where the values are defined at Wikibase/DataModel: The  function returns an empty string when there is no precision, or the property is not a date, or the current page is not connected. This can cause problems in templates if an attempt is made to compare the returned value with a number, so this template traps that and returns either the second unnamed parameter or 0 if that is not supplied.
 * 0 - billion years, 1 - hundred million years, ..., 6 - millennia, 7 - century, 8 - decade, 9 - year, 10 - month, 11 - day

Examples

 * No qid:  →
 * No qid, default set to 99:  →
 * No qid:  →
 * No qid, default set to 99:  →

Testing for precision can be done like this, and the default output can be changed by assigning the default a large number:
 * No qid:  →
 * No qid, default set to 99:  →
 * No qid:  →
 * No qid, default set to 99:  →