From cf4033d9e77993aede4c94349c87379a65893319 Mon Sep 17 00:00:00 2001
From: Philipp Gesang <phg42.2a@gmail.com>
Date: Wed, 7 Aug 2013 13:11:10 +0200
Subject: sync with Context as of date

---
 Makefile            |  1 +
 lualibs-boolean.lua |  4 ++--
 lualibs-io.lua      |  2 +-
 lualibs-os.lua      | 24 ++++++++++++++++++------
 4 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/Makefile b/Makefile
index 556e56f..f04503a 100644
--- a/Makefile
+++ b/Makefile
@@ -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)
-- 
cgit v1.2.3