From cf4033d9e77993aede4c94349c87379a65893319 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 7 Aug 2013 13:11:10 +0200 Subject: sync with Context as of date --- lualibs-os.lua | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'lualibs-os.lua') diff --git a/lualibs-os.lua b/lualibs-os.lua index a4c0ac8..3838b55 100644 --- a/lualibs-os.lua +++ b/lualibs-os.lua @@ -382,31 +382,43 @@ end local timeformat = format("%%s%s",os.timezone(true)) local dateformat = "!%Y-%m-%d %H:%M:%S" +local lasttime = nil +local lastdate = nil function os.fulltime(t,default) - t = tonumber(t) or 0 + t = t and tonumber(t) or 0 if t > 0 then -- valid time elseif default then return default else - t = nil + t = time() end - return format(timeformat,date(dateformat,t)) + if t ~= lasttime then + lasttime = t + lastdate = format(timeformat,date(dateformat)) + end + return lastdate end local dateformat = "%Y-%m-%d %H:%M:%S" +local lasttime = nil +local lastdate = nil function os.localtime(t,default) - t = tonumber(t) or 0 + t = t and tonumber(t) or 0 if t > 0 then -- valid time elseif default then return default else - t = nil + t = time() + end + if t ~= lasttime then + lasttime = t + lastdate = date(dateformat,t) end - return date(dateformat,t) + return lastdate end function os.converttime(t,default) -- cgit v1.2.3