Anonymous user
Module:Convert: Difference between revisions
update from sandbox per Template talk:Convert#Module version 7
(update from sandbox per Template talk:Convert#Module version 6) |
(update from sandbox per Template talk:Convert#Module version 7) |
||
Line 1,333:
-- altvalue = a valid number, usually same as value but different
-- if fraction used (for hands unit)
-- singular = true if value is 1 or -1 (to use singular form of units)
-- clean = cleaned text with any separators and sign removed
-- (en digits and '.' decimal mark)
Line 1,401 ⟶ 1,400:
end
if show == nil then
singular = (value == 1
local precision = parms.input_precision
if precision and 0 <= precision and precision <= 8 then
Line 1,781 ⟶ 1,780:
parms.opt_values = true
end
local align = format('
parms.table_joins = { align .. '|', '\n|' .. align .. '|' }
end
Line 2,274 ⟶ 2,273:
-- show = rounded, formatted string with the result of converting value in info,
-- using the rounding specified in parms.
-- singular = true if result
-- is "1", or like "1.00", or is a fraction with value < 1;
-- (and more fields shown below, and a calculated 'absvalue' field).
-- or return true, nil if no value specified;
Line 2,362 ⟶ 2,361:
end
local t = format_number(parms, show, exponent, isnegative)
t.singular = (type(show) == 'string' and (show == '1' or show:match('^1%.0*$') ~= nil) and not isnegative)▼
t.singular = (exponent == 1 and show:match('^10*$'))
else▼
▲
end▼
t.fraction_table = show
t.singular = (outvalue <= 1) -- cannot have 'fraction == 1', but if it were possible it would be singular
end▼
t.raw_absvalue = outvalue -- absolute value before rounding
return true, setmetatable(t, {
Line 2,733 ⟶ 2,740:
local usename = unit_table.usename
local singular = info.singular
▲ if want_link then
▲ else
▲ if inout == 'in' then
▲ else
▲ end
▲ end
local want_name
if usename then
Line 2,901 ⟶ 2,886:
local join1 = parms.joins[1]
if join1 == ' (' or join1 == ' [' then
parms.joins = {
end
end
|