X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/86e57ee7249734545974d4b8ba2de3bcea6575a3..bab202dc11e948f75e617b39024dc67f9a11691f:/src/timetable.lua?ds=sidebyside diff --git a/src/timetable.lua b/src/timetable.lua index e7f2816..1ce701c 100644 --- a/src/timetable.lua +++ b/src/timetable.lua @@ -1,3 +1,4 @@ +local strformat = string.format local floor = math.floor local function idiv ( n , d ) return floor ( n / d ) @@ -151,6 +152,9 @@ local timetable_mt = { __index = timetable_methods ; __tostring = timetable_methods.rfc_3339 ; __eq = function ( a , b ) + return a:timestamp() == b:timestamp() + end ; + __lt = function ( a , b ) return a:timestamp() < b:timestamp() end ; } @@ -170,12 +174,17 @@ local function new_timetable ( year , month , day , hour , min , sec ) } end +local function new_from_timestamp ( ts ) + return new_timetable ( 1970 , 1 , 1 , 0 , 0 , ts ) +end + return { doomsday = doomsday ; normalise = normalise ; timestamp = timestamp ; new = new_timetable ; + new_from_timestamp = new_from_timestamp ; cast = cast_timetable ; timetable_mt = timetable_mt ; }