From 53b97cc350b4807b2ba541c99d6614c9d916f174 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Sat, 14 Sep 2013 22:16:37 +0200 Subject: [PATCH] fixed vararg usage for lua 5.1/5.2. Fixes #1 --- date.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/date.lua b/date.lua index 7910a62..f6855de 100644 --- a/date.lua +++ b/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