From 559b74f2263f649dab60af846949536cbbb4b10c Mon Sep 17 00:00:00 2001 From: daurnimator Date: Fri, 29 Aug 2014 16:57:26 -0400 Subject: [PATCH] luatz/init: Add `now()` function --- doc/index.md | 5 +++++ luatz/init.lua | 5 +++++ 2 files changed, 10 insertions(+) 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 ) -- 2.39.5