]> 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:

rockspec: Remove < 5.3 requirement, add supported environments to README
[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 _M.now = function ( )
21         local ts = _M.gettime.gettime ( )
22         return _M.timetable.new_from_timestamp ( ts )
23 end
24
25 --- C-like functions
26
27 _M.gmtime = function ( ts )
28         return _M.timetable.new_from_timestamp ( ts )
29 end
30
31 _M.localtime = function ( ts )
32         ts = _M.time_in ( nil , ts )
33         return _M.gmtime ( ts )
34 end
35
36 _M.ctime = function ( ts )
37         return _M.strftime.asctime ( _M.localtime ( ts ) )
38 end
39
40 return _M