Bumper commit for the new modulemanager API \o/ Updates all the modules, though some...
[prosody.git] / plugins / mod_time.lua
1 \r
2 local st = require "util.stanza";\r
3 local datetime = require "util.datetime".datetime;\r
4 local legacy = require "util.datetime".legacy;\r
5 \r
6 -- XEP-0202: Entity Time\r
7 \r
8 require "core.discomanager".set("time", "urn:xmpp:time");\r
9 \r
10 module:add_iq_handler({"c2s", "s2sin"}, "urn:xmpp:time",\r
11         function(session, stanza)\r
12                 if stanza.attr.type == "get" then\r
13                         session.send(st.reply(stanza):tag("time", {xmlns="urn:xmpp:time"})\r
14                                 :tag("tzo"):text("+00:00"):up() -- FIXME get the timezone in a platform independent fashion\r
15                                 :tag("utc"):text(datetime()));\r
16                 end\r
17         end);\r
18 \r
19 -- XEP-0090: Entity Time (deprecated)\r
20 \r
21 require "core.discomanager".set("time", "jabber:iq:time");\r
22 \r
23 module:add_iq_handler({"c2s", "s2sin"}, "jabber:iq:time",\r
24         function(session, stanza)\r
25                 if stanza.attr.type == "get" then\r
26                         session.send(st.reply(stanza):tag("query", {xmlns="jabber:iq:time"})\r
27                                 :tag("utc"):text(legacy()));\r
28                 end\r
29         end);\r