Module:DatesWD and Module:DatesWD/sandbox: Difference between pages
Appearance
(Difference between pages)
Content deleted Content added
No edit summary |
Slight simplifications |
||
Line 7: | Line 7: | ||
if str == "" or str == nil then |
if str == "" or str == nil then |
||
return nil |
return nil |
||
elseif |
elseif tonumber(str) then |
||
return math.floor(tonumber(str)) |
return math.floor(tonumber(str)) |
||
else |
else |
||
Line 16: | Line 16: | ||
local function inbord(val, down, up) |
local function inbord(val, down, up) |
||
return not (type(up) ~= "number" or type(down) ~= "number" or type(val) ~= "number" or up < down or val < down or val > up) |
|||
return false |
|||
else |
|||
return true |
|||
end |
|||
end |
end |
||
local function isdate ( chain ) |
local function isdate ( chain ) |
||
return (type(chain == "table") |
|||
and inbord(chain.year,-9999,9999) |
|||
and inbord(chain.month,1,12) |
|||
and inbord(chain.day,1,31)) |
|||
then return false |
|||
else return true end |
|||
-- more detailed check for 31.02.0000 needed |
-- more detailed check for 31.02.0000 needed |
||
-- check for other calendars needed |
-- check for other calendars needed |