Zum Inhalt springen

Modul:TwitterSnowflake: Unterschied zwischen den Versionen

allow inclusion of letter after date, as is frequently done on pages using harvrefs
K (local two32 instead of calculating 2^32 3x)
(allow inclusion of letter after date, as is frequently done on pages using harvrefs)
Zeile 7: Zeile 7:
local epoch = tonumber(frame.args.epoch) or 1288834974
local epoch = tonumber(frame.args.epoch) or 1288834974
local id_str = frame.args.id_str
local id_str = frame.args.id_str
mw.log(id_str)
if type(id_str) ~= "string" then error("bad argument #1 (expected string, got " .. type(id_str) .. ")", 2) end
if type(id_str) ~= "string" then error("bad argument #1 (expected string, got " .. type(id_str) .. ")", 2) end
if type(format) ~= "string" then error("bad argument #2 (expected string, got " .. type(format) .. ")", 2) end
if type(format) ~= "string" then error("bad argument #2 (expected string, got " .. type(format) .. ")", 2) end
Zeile 31: Zeile 32:
end
end
frame.args.format = "%B %e, %Y"
frame.args.format = "%B %e, %Y"
frame.args.date = mw.ustring.gsub(frame.args.date, "(%d%d%d%d)%a", "%1")
frame.args.epoch = tonumber(frame.args.epoch) or 1288834974
frame.args.epoch = tonumber(frame.args.epoch) or 1288834974
local epochdate = Date(os.date("%B %e, %Y", frame.args.epoch))
local epochdate = Date(os.date("%B %e, %Y", frame.args.epoch))
Zeile 38: Zeile 40:
end
end
local date = Date(frame.args.date) or 0 -- if we error here, then an input of no date causes an error, which is contrary to the entire way {{TwitterSnowflake/datecheck}} works
local date = Date(frame.args.date) or 0 -- if we error here, then an input of no date causes an error, which is contrary to the entire way {{TwitterSnowflake/datecheck}} works
mw.log(date)
return date - twitterdate
return date - twitterdate
end
end
Anonymer Benutzer