util.datetime: Allow specifying a time to format

This commit is contained in:
Matthew Wild 2009-03-29 02:14:32 +01:00
parent 3ab003a514
commit 5ce49a3b6c

View file

@ -7,31 +7,31 @@
-- --
-- XEP-0082: XMPP Date and Time Profiles -- XEP-0082: XMPP Date and Time Profiles
local os_date = os.date; local os_date = os.date;
local error = error; local error = error;
module "datetime" module "datetime"
function date() function date(t)
return os_date("!%Y-%m-%d"); return os_date("!%Y-%m-%d", t);
end end
function datetime() function datetime(t)
return os_date("!%Y-%m-%dT%H:%M:%SZ"); return os_date("!%Y-%m-%dT%H:%M:%SZ", t);
end end
function time() function time(t)
return os_date("!%H:%M:%S"); return os_date("!%H:%M:%S", t);
end end
function legacy() function legacy(t)
return os_date("!%Y%m%dT%H:%M:%S"); return os_date("!%Y%m%dT%H:%M:%S", t);
end end
function parse(s) function parse(s)
error("datetime.parse: Not implemented"); -- TODO error("datetime.parse: Not implemented"); -- TODO
end end
return _M; return _M;