Modul:TwitterSnowflake: Unterschied zwischen den Versionen

Undid revision 1001179022 by Elliot321 (talk)
(copy from sandbox (all testcases match))
(Undid revision 1001179022 by Elliot321 (talk))
Zeile 13: Zeile 13:
local hiexp = 1
local hiexp = 1
for c in id_str:gmatch(".") do
for c in id_str:gmatch(".") do
lo = lo * 10 + c
lo = lo * 10 + tostring(c)
if lo >= 2^32 then
if lo >= 2^32 then
hi, lo = hi * 10^hiexp + math.floor(lo / 2^32), lo % 2^32
hi, lo = hi * 10^hiexp + math.floor(lo / 2^32), lo % 2^32
Zeile 26: Zeile 26:
function p.getDate(frame)
function p.getDate(frame)
-- just pass frame directly to snowflakeToDate, this wraps it but the args are the same plus
-- just pass frame directly to snowflakeToDate, this wraps it but the args are the same plus
if (frame.args.id_str):match("%D") then -- not a number, so return -2
return -2
end
frame.args.format = "%B %e, %Y"
frame.args.format = "%B %e, %Y"
frame.args.epoch = tonumber(frame.args.epoch) or 1288834974
frame.args.epoch = tonumber(frame.args.epoch) or 1288834974
Zeile 36: Zeile 33:
return -1
return -1
end
end
local date = Date(frame.args.date) or error("cite tweet: invalid date", 0)
return Date(frame.args.date) - twitterdate
return date - twitterdate
end
end


return p
return p
Anonymer Benutzer