From: daurnimator Date: Tue, 23 Jul 2013 22:54:07 +0000 (-0400) Subject: src/timetable: Add rfc_3339 method X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/88cbee758e827b9b3a1c9a6be61f1fc3d65b6575 src/timetable: Add rfc_3339 method --- diff --git a/src/timetable.lua b/src/timetable.lua index 9b78576..c71c59b 100644 --- a/src/timetable.lua +++ b/src/timetable.lua @@ -134,8 +134,14 @@ function timetable_methods:timestamp ( ) return timestamp ( unpack_tm ( self ) ) end +function timetable_methods:rfc_3339 ( ) + -- %06.4g gives 3 (=6-4+1) digits after decimal + return strformat ( "%04u-%02u-%02uT%02u:%02u:%06.4g" , unpack_tm ( self ) ) +end + local timetable_mt = { __index = timetable_methods ; + __tostring = timetable_methods.rfc_3339 ; __eq = function ( a , b ) return a:timestamp() < b:timestamp() end ;