diff options
author | Philipp Gesang <phg42.2a@gmail.com> | 2013-08-07 13:11:10 +0200 |
---|---|---|
committer | Philipp Gesang <phg42.2a@gmail.com> | 2013-08-07 13:11:10 +0200 |
commit | cf4033d9e77993aede4c94349c87379a65893319 (patch) | |
tree | 089935a8518f2b2a333fc0d608eae849ba0582c5 /lualibs-os.lua | |
parent | 2c4bb4e4fee25ed79f6183bff9200eba168c021d (diff) | |
download | lualibs-cf4033d9e77993aede4c94349c87379a65893319.tar.gz |
sync with Context as of date
Diffstat (limited to 'lualibs-os.lua')
-rw-r--r-- | lualibs-os.lua | 24 |
1 files changed, 18 insertions, 6 deletions
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) |