X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/12a8febabf1d5fe90d7c623377507d28a0f0fc80..85c40964551cb74c3d6ef6bf61a12fd79013389b:/luatz/timetable.lua diff --git a/luatz/timetable.lua b/luatz/timetable.lua index e1649a0..6cded31 100644 --- a/luatz/timetable.lua +++ b/luatz/timetable.lua @@ -143,23 +143,23 @@ function timetable_methods:rfc_3339 ( ) return strformat ( "%04u-%02u-%02uT%02u:%02u:%06.3f" , self:unpack ( ) ) end -local timetable_mt +local strftime = require "luatz.strftime".strftime +function timetable_methods:strftime ( format_string ) + return strftime ( format_string , self ) +end -local function coerce_arg ( t ) - if getmetatable ( t ) == timetable_mt then - return t:timestamp ( ) - end - return t +function timetable_methods:asctime ( ) + return self:strftime ( "%c\n" ) end -timetable_mt = { +local timetable_mt = { __index = timetable_methods ; __tostring = timetable_methods.rfc_3339 ; __eq = function ( a , b ) - return coerce_arg ( a ) == coerce_arg ( b ) + return a:timestamp ( ) == b:timestamp ( ) end ; __lt = function ( a , b ) - return coerce_arg ( a ) < coerce_arg ( b ) + return a:timestamp ( ) < b:timestamp ( ) end ; }