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 | |
parent | 2c4bb4e4fee25ed79f6183bff9200eba168c021d (diff) | |
download | lualibs-cf4033d9e77993aede4c94349c87379a65893319.tar.gz |
sync with Context as of date
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | lualibs-boolean.lua | 4 | ||||
-rw-r--r-- | lualibs-io.lua | 2 | ||||
-rw-r--r-- | lualibs-os.lua | 24 |
4 files changed, 22 insertions, 9 deletions
@@ -112,5 +112,6 @@ clean: mrproper: clean @$(RM) -- $(GENERATED) $(ZIPS) + @$(RM) -r $(DISTDIR) merge: $(MERGED) diff --git a/lualibs-boolean.lua b/lualibs-boolean.lua index f087f1a..8d11080 100644 --- a/lualibs-boolean.lua +++ b/lualibs-boolean.lua @@ -59,9 +59,9 @@ end function string.is_boolean(str,default) if type(str) == "string" then - if str == "true" or str == "yes" or str == "on" or str == "t" then + if str == "true" or str == "yes" or str == "on" or str == "t" or str == "1" then return true - elseif str == "false" or str == "no" or str == "off" or str == "f" then + elseif str == "false" or str == "no" or str == "off" or str == "f" or str == "0" then return false end end diff --git a/lualibs-io.lua b/lualibs-io.lua index e3a443b..52f166a 100644 --- a/lualibs-io.lua +++ b/lualibs-io.lua @@ -60,7 +60,7 @@ io.readall = readall function io.loaddata(filename,textmode) -- return nil if empty local f = io.open(filename,(textmode and 'r') or 'rb') if f then --- local data = f:read('*all') + -- local data = f:read('*all') local data = readall(f) f:close() if #data > 0 then 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) |