X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/85c40964551cb74c3d6ef6bf61a12fd79013389b..94c5a08ebdc03125f84e7fed814a1599c788a09e:/luatz/init.lua?ds=sidebyside diff --git a/luatz/init.lua b/luatz/init.lua index 2660715..923e4d6 100644 --- a/luatz/init.lua +++ b/luatz/init.lua @@ -1,13 +1,15 @@ local _M = { + gettime = require "luatz.gettime" ; parse = require "luatz.parse" ; strftime = require "luatz.strftime" ; timetable = require "luatz.timetable" ; + tzcache = require "luatz.tzcache" ; } --- Top-level aliases for common functions -_M.time = require "luatz.gettime".gettime -_M.get_tz = require "luatz.tzcache".get_tz +_M.time = _M.gettime.gettime +_M.get_tz = _M.tzcache.get_tz --- Handy functions @@ -15,4 +17,19 @@ _M.time_in = function ( tz , now ) return _M.get_tz ( tz ):localize ( now ) end +--- C-like functions + +_M.gmtime = function ( ts ) + return _M.timetable.new_from_timestamp ( ts ) +end + +_M.localtime = function ( ts ) + ts = _M.time_in ( nil , ts ) + return _M.gmtime ( ts ) +end + +_M.ctime = function ( ts ) + return _M.strftime.asctime ( _M.localtime ( ts ) ) +end + return _M