Module:MOS: Difference between revisions

Ganaram inukshuk (talk | contribs)
Bugfixed interval_as_string for zero-counts
Ganaram inukshuk (talk | contribs)
m moar bugfixes to interval-as-string
Line 95: Line 95:
-- where i and j are the quantities for L and s.
-- where i and j are the quantities for L and s.
function p.interval_as_string(interval)
function p.interval_as_string(interval)
local L_string = ""
local s_string = ""
-- Quantity of L's as a string
-- Quantity of L's as a string
local L_string = ""
if interval['L'] == 0 then
if interval['L'] == 0 then
L_string = ""
L_string = ""
Line 108: Line 107:
-- Quantity of s's as a string
-- Quantity of s's as a string
local s_string = ""
if math.abs(interval['s']) == 0 then
if math.abs(interval['s']) == 0 then
L_string = ""
s_string = ""
elseif math.abs(interval['s']) == 1 then
elseif math.abs(interval['s']) == 1 then
L_string = "s"
s_string = "s"
else
else
L_string = string.format("%ds", math.abs(interval['s']))
s_string = string.format("%ds", math.abs(interval['s']))
end
end
if L_string == "" and s_string == "" then
if interval['L'] == 0 and interval['s'] == 0 then
return "0"
return "0"
elseif L_string ~= "" and s_string == "" then  
elseif interval['L'] == 0 and interval['s'] ~= 0 then  
return L_string
return L_string
elseif L_string == "" and s_string ~= "" then  
elseif interval['L'] ~= 0 and interval['s'] == 0 then  
return s_string
return s_string
else
else