Software /
code /
prosody
Annotate
util/datetime.lua @ 1591:aaa1bcb7af98
mod_xmlrpc: Remove file and line number from XML-RPC errors
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sat, 25 Jul 2009 19:58:24 +0500 |
parent | 1523:841d61be198f |
child | 2923:b7049746bd29 |
rev | line source |
---|---|
1523
841d61be198f
Remove version number from copyright headers
Matthew Wild <mwild1@gmail.com>
parents:
921
diff
changeset
|
1 -- Prosody IM |
760
90ce865eebd8
Update copyright notices for 2009
Matthew Wild <mwild1@gmail.com>
parents:
759
diff
changeset
|
2 -- Copyright (C) 2008-2009 Matthew Wild |
90ce865eebd8
Update copyright notices for 2009
Matthew Wild <mwild1@gmail.com>
parents:
759
diff
changeset
|
3 -- Copyright (C) 2008-2009 Waqas Hussain |
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
4 -- |
758 | 5 -- This project is MIT/X11 licensed. Please see the |
6 -- COPYING file in the source package for more information. | |
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
7 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
8 |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
9 |
921
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
10 -- XEP-0082: XMPP Date and Time Profiles |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
11 |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
12 local os_date = os.date; |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
13 local error = error; |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
14 |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
15 module "datetime" |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
16 |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
17 function date(t) |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
18 return os_date("!%Y-%m-%d", t); |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
19 end |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
20 |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
21 function datetime(t) |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
22 return os_date("!%Y-%m-%dT%H:%M:%SZ", t); |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
23 end |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
24 |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
25 function time(t) |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
26 return os_date("!%H:%M:%S", t); |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
27 end |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
28 |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
29 function legacy(t) |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
30 return os_date("!%Y%m%dT%H:%M:%S", t); |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
31 end |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
32 |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
33 function parse(s) |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
34 error("datetime.parse: Not implemented"); -- TODO |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
35 end |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
36 |
f97d37a7d8a6
util.datetime: Allow specifying a time to format
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
37 return _M; |