]> git.madduck.net Git - etc/awesome.git/blob - luatz/init.lua

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

doc/timetable: spell check
[etc/awesome.git] / luatz / init.lua
1 local _M = {
2         gettime = require "luatz.gettime" ;
3         parse = require "luatz.parse" ;
4         strftime = require "luatz.strftime" ;
5         timetable = require "luatz.timetable" ;
6         tzcache = require "luatz.tzcache" ;
7 }
8
9 --- Top-level aliases for common functions
10
11 _M.time = _M.gettime.gettime
12 _M.get_tz = _M.tzcache.get_tz
13
14 --- Handy functions
15
16 _M.time_in = function ( tz , now )
17         return _M.get_tz ( tz ):localize ( now )
18 end
19
20 --- C-like functions
21
22 _M.gmtime = function ( ts )
23         return _M.timetable.new_from_timestamp ( ts ):normalise ( )
24 end
25
26 _M.localtime = function ( ts )
27         ts = _M.time_in ( nil , ts )
28         return _M.gmtime ( ts )
29 end
30
31 _M.ctime = function ( ts )
32         return _M.strftime.asctime ( _M.localtime ( ts ) )
33 end
34
35 return _M