From 88cbee758e827b9b3a1c9a6be61f1fc3d65b6575 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Tue, 23 Jul 2013 18:54:07 -0400 Subject: [PATCH 1/1] src/timetable: Add rfc_3339 method --- src/timetable.lua | 6 ++++++ 1 file changed, 6 insertions(+) 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 ; -- 2.39.5