Modulo:Wikidata/Formatters/frequency
Dokumentado por ĉi tiu modulo povas esti kreata ĉe Modulo:Wikidata/Formatters/frequency/dokumentado
require('strict')
local p = {}
local parent = require 'Modulo:Wikidata/Formatters/quantity'
p.getRawValue = parent.getRawValue
local function isPositiveInteger(value)
if value > 0 then
local int, fract = math.modf(value)
if int == value then
return true
end
end
return false
end
function p.formatNumber(value, options)
-- todo: 0.5 days -> twice a day
if isPositiveInteger(value) then
if value == 1 then
return 'každý'
else
return mw.ustring.format('každý %d.', value)
end
else
return parent.formatNumber(value, options)
end
end
p.formatRawValue = p.formatNumber
function p.formatValue(value, options)
parent.setFormatNumber(p.formatNumber)
return parent._formatValue(value, options)
end
return p