2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 Waqas Hussain
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
9 local st
= require
"util.stanza";
10 local datetime
= require
"util.datetime".datetime
;
11 local legacy
= require
"util.datetime".legacy
;
13 -- XEP-0202: Entity Time
15 module
:add_feature("urn:xmpp:time");
17 local function time_handler(event
)
18 local origin
, stanza
= event
.origin
, event
.stanza
;
19 origin
.send(st
.reply(stanza
):tag("time", {xmlns
="urn:xmpp:time"})
20 :tag("tzo"):text("+00:00"):up() -- TODO get the timezone in a platform independent fashion
21 :tag("utc"):text(datetime()));
25 module
:hook("iq-get/bare/urn:xmpp:time:time", time_handler
);
26 module
:hook("iq-get/host/urn:xmpp:time:time", time_handler
);
28 -- XEP-0090: Entity Time (deprecated)
30 module
:add_feature("jabber:iq:time");
32 local function legacy_time_handler(event
)
33 local origin
, stanza
= event
.origin
, event
.stanza
;
34 origin
.send(st
.reply(stanza
):tag("query", {xmlns
="jabber:iq:time"})
35 :tag("utc"):text(legacy()));
39 module
:hook("iq-get/bare/jabber:iq:time:query", legacy_time_handler
);
40 module
:hook("iq-get/host/jabber:iq:time:query", legacy_time_handler
);