summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraalatchm <aalatchm@jamailca.com>2011-03-22 18:27:12 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2011-03-22 20:58:54 +0000
commit7882795d10fc28a696a4784d24fbb2990a5e5707 (patch)
tree03b17be8b476a6d7d9e2d68daee98457d0d49a16
parent129ad98fe0e178a1b5c3870074eb28bf1b80ba67 (diff)
downloadposixtz-0.2.tar.bz2
posixtz-0.2.tar.xz
added to Lua example to demonstrate posixtz.parsev0.2
-rw-r--r--example.lua32
1 files changed, 32 insertions, 0 deletions
diff --git a/example.lua b/example.lua
index f140553..dad7154 100644
--- a/example.lua
+++ b/example.lua
@@ -4,3 +4,35 @@ require("posixtz")
print(posixtz.from_file("/usr/share/zoneinfo/Europe/Stockholm"))
+
+t = posixtz.parse("CET-1CEST,M3.5.0,M10.5.0/3")
+
+local out = ""
+out = out .. "POSIX TZ: '"..t.std.."'\n"
+out = out .. "GMT Offset, where positive is West of GMT: '"..t.offset.total.."'\n"
+
+if t.dst then
+ out = out .. "DST zone is called '"..t.dst.name.."'\n"
+ local function dstinfo (pos)
+ local info = ""
+ if t.dst[pos].hour then
+ info = info .. "at '"..t.dst[pos].hour.."' hours (0-23) "
+ end
+ if t.dst[pos].week then
+ info = info .. "on weekday '"..t.dst[pos].weekday.."' "
+ info = info .. "of week '"..t.dst[pos].week.."' "
+ info = info .. "of the month '"..t.dst[pos].month.."'"
+ else
+ info = info .. "on day '"..t.dst[pos].day.."' "
+ info = info .. "of month '"..t.dst[pos].month.."'"
+ end
+ return info
+ end
+ out = out .. "DST begins "
+ out = out .. dstinfo("start") .. "\n"
+ out = out .. "DST ends "
+ out = out .. dstinfo("stop") .. "\n"
+
+end
+
+io.write(out)