mirror of
https://github.com/TangentFoxy/lua-date.git
synced 2025-07-28 02:52:18 +00:00
fixed vararg usage for lua 5.1/5.2. Fixes #1
This commit is contained in:
8
date.lua
8
date.lua
@@ -32,6 +32,7 @@
|
||||
local math = math
|
||||
local os = os
|
||||
local unpack = unpack or table.unpack
|
||||
local pack = table.pack or function(...) return { n = select('#', ...), ... } end
|
||||
local setmetatable = setmetatable
|
||||
local getmetatable = getmetatable
|
||||
--[[ EXTRA FUNCTIONS ]]--
|
||||
@@ -403,6 +404,7 @@
|
||||
end
|
||||
--#end -- not DATE_OBJECT_AFX
|
||||
local function date_from(...)
|
||||
local arg = pack(...)
|
||||
local y, m, d = fix(arg[1]), getmontharg(arg[2]), fix(arg[3])
|
||||
local h, r, s, t = tonumber(arg[4] or 0), tonumber(arg[5] or 0), tonumber(arg[6] or 0), tonumber(arg[7] or 0)
|
||||
if y and m and d and h and r and s and t then
|
||||
@@ -700,9 +702,9 @@
|
||||
end
|
||||
|
||||
function date:__call(...)
|
||||
local n = arg.n
|
||||
if n > 1 then return (date_from(unpack(arg)))
|
||||
elseif n == 0 then return (date_getdobj(false))
|
||||
local arg = pack(...)
|
||||
if arg.n > 1 then return (date_from(...))
|
||||
elseif arg.n == 0 then return (date_getdobj(false))
|
||||
else local o, r = date_getdobj(arg[1]); return r and o:copy() or o end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user