From 36d88e5726e9d7da88fca3efd0d6f824d6254e46 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Mon, 18 Aug 2014 11:53:09 -0400 Subject: [PATCH] luatz/init: Add C-like functions for some common tasks --- luatz/init.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/luatz/init.lua b/luatz/init.lua index 91c95dd..02b07ba 100644 --- a/luatz/init.lua +++ b/luatz/init.lua @@ -17,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 ):normalise ( ) +end + +_M.localtime = function ( ts ) + ts = _M.time_in ( nil , ts ) + return _M.gmtime ( ts ) +end + +_M.ctime = function ( ts ) + return _M.localtime ( ts ):asctime ( ) +end + return _M -- 2.39.5