From: daurnimator Date: Fri, 29 Aug 2014 20:57:26 +0000 (-0400) Subject: luatz/init: Add `now()` function X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/559b74f2263f649dab60af846949536cbbb4b10c luatz/init: Add `now()` function --- diff --git a/doc/index.md b/doc/index.md index 2b7872d..e0ece6a 100644 --- a/doc/index.md +++ b/doc/index.md @@ -13,6 +13,11 @@ The table includes the following sub modules, which have their own documentation Returns the current unix timestamp using the most precise source available. See `gettime` for more information. +### `now ( )` + +Returns the current time as a timetable object +See `timetable` for more information + ### `get_tz ( [timezone_name] )` diff --git a/luatz/init.lua b/luatz/init.lua index 923e4d6..1a6c835 100644 --- a/luatz/init.lua +++ b/luatz/init.lua @@ -17,6 +17,11 @@ _M.time_in = function ( tz , now ) return _M.get_tz ( tz ):localize ( now ) end +_M.now = function ( ) + local ts = _M.gettime.gettime ( ) + return _M.timetable.new_from_timestamp ( ts ) +end + --- C-like functions _M.gmtime = function ( ts )