Update copyright notices for 2009
[prosody.git] / plugins / mod_time.lua
1 -- Prosody IM v0.3
2 -- Copyright (C) 2008-2009 Matthew Wild
3 -- Copyright (C) 2008-2009 Waqas Hussain
4 -- 
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
7 --
8
9
10 \r
11 local st = require "util.stanza";\r
12 local datetime = require "util.datetime".datetime;\r
13 local legacy = require "util.datetime".legacy;\r
14 \r
15 -- XEP-0202: Entity Time\r
16 \r
17 module:add_feature("urn:xmpp:time");\r
18 \r
19 module:add_iq_handler({"c2s", "s2sin"}, "urn:xmpp:time",\r
20         function(session, stanza)\r
21                 if stanza.attr.type == "get" then\r
22                         session.send(st.reply(stanza):tag("time", {xmlns="urn:xmpp:time"})\r
23                                 :tag("tzo"):text("+00:00"):up() -- FIXME get the timezone in a platform independent fashion\r
24                                 :tag("utc"):text(datetime()));\r
25                 end\r
26         end);\r
27 \r
28 -- XEP-0090: Entity Time (deprecated)\r
29 \r
30 module:add_feature("jabber:iq:time");\r
31 \r
32 module:add_iq_handler({"c2s", "s2sin"}, "jabber:iq:time",\r
33         function(session, stanza)\r
34                 if stanza.attr.type == "get" then\r
35                         session.send(st.reply(stanza):tag("query", {xmlns="jabber:iq:time"})\r
36                                 :tag("utc"):text(legacy()));\r
37                 end\r
38         end);\r