6926c66b16
* Add missing globals from luacheck config * Fix luacheck warnings in all lua files * Re-enable luacheck in Travis * Speed up Travis by using preinstalled LuaRocks * Fix more luacheck warnings in httpserver lua module * Fix DCC module and add appropriate definitions to luacheck config. * Change inline comments from ignoring block to only ignore specific line * Add Luacheck for Windows and enable it for both Windows and Linux * Change luacheck exceptions and fix errors from 1st round of polishing * Add retry and timeout params to wget |
||
---|---|---|
.. | ||
README.md | ||
alaska.zone | ||
central.zone | ||
eastern.zone | ||
mountain.zone | ||
pacific.zone | ||
tz.lua |
README.md
tz module
This is a simple module that parses timezone files as found on unix systems. It is oriented around converting the current time. It can convert other times, but it is rather less efficient as it maintains only a single cached entry in memory.
On my linux system, these files can be found in /usr/share/zoneinfo
.
tz.setzone()
This sets the timezone to be used in subsequent conversions
Syntax
tz.setzone(timezone)
Parameters
timezone
this is the timezone string. It must correspond to a file in the file system which is named timezone.zone.
Returns
true if the zone exists in the file system.
tz.getoffset()
This gets the offset (in seconds) of the time passed as the argument.
Syntax
tz.getoffset(time)
Parameters
time
the number of seconds since the epoch. This is the same value as used by thesntp
module.
Returns
- The number of seconds of offset. West of Greenwich is negative.
- The start time (in epoch seconds) of this offset.
- The end time (in epoch seconds) of this offset.
Example
tz = require('tz')
tz.setzone('eastern')
sntp.sync(nil, function(now)
local tm = rtctime.epoch2cal(now + tz.getoffset(now))
print(string.format("%04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"]))
end)
tz.getzones()
This returns a list of the available timezones in the file system.
Syntax
tz.getzones()
Returns
A list of timezones.