util.datetime: Allow specifying a time to format
[prosody.git] / util / datetime.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 -- XEP-0082: XMPP Date and Time Profiles
11
12 local os_date = os.date;
13 local error = error;
14
15 module "datetime"
16
17 function date(t)
18         return os_date("!%Y-%m-%d", t);
19 end
20
21 function datetime(t)
22         return os_date("!%Y-%m-%dT%H:%M:%SZ", t);
23 end
24
25 function time(t)
26         return os_date("!%H:%M:%S", t);
27 end
28
29 function legacy(t)
30         return os_date("!%Y%m%dT%H:%M:%S", t);
31 end
32
33 function parse(s)
34         error("datetime.parse: Not implemented"); -- TODO
35 end
36
37 return _M;