mod_time Convert from Windows line endings
[prosody.git] / plugins / mod_time.lua
1 -- Prosody IM v0.4
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
11 local st = require "util.stanza";
12 local datetime = require "util.datetime".datetime;
13 local legacy = require "util.datetime".legacy;
14
15 -- XEP-0202: Entity Time
16
17 module:add_feature("urn:xmpp:time");
18
19 module:add_iq_handler({"c2s", "s2sin"}, "urn:xmpp:time",
20         function(session, stanza)
21                 if stanza.attr.type == "get" then
22                         session.send(st.reply(stanza):tag("time", {xmlns="urn:xmpp:time"})
23                                 :tag("tzo"):text("+00:00"):up() -- FIXME get the timezone in a platform independent fashion
24                                 :tag("utc"):text(datetime()));
25                 end
26         end);
27
28 -- XEP-0090: Entity Time (deprecated)
29
30 module:add_feature("jabber:iq:time");
31
32 module:add_iq_handler({"c2s", "s2sin"}, "jabber:iq:time",
33         function(session, stanza)
34                 if stanza.attr.type == "get" then
35                         session.send(st.reply(stanza):tag("query", {xmlns="jabber:iq:time"})
36                                 :tag("utc"):text(legacy()));
37                 end
38         end);