Software /
code /
prosody
Annotate
util/datetime.lua @ 615:4ae3e81513f3
0.1 -> 0.2
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 10 Dec 2008 15:44:03 +0000 |
parent | 519:cccd610a0ef9 |
child | 758:b1885732e979 |
rev | line source |
---|---|
615 | 1 -- Prosody IM v0.2 |
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
2 -- Copyright (C) 2008 Matthew Wild |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
3 -- Copyright (C) 2008 Waqas Hussain |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
4 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
5 -- This program is free software; you can redistribute it and/or |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
6 -- modify it under the terms of the GNU General Public License |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
7 -- as published by the Free Software Foundation; either version 2 |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
8 -- of the License, or (at your option) any later version. |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
9 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
10 -- This program is distributed in the hope that it will be useful, |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
13 -- GNU General Public License for more details. |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
14 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
15 -- You should have received a copy of the GNU General Public License |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
16 -- along with this program; if not, write to the Free Software |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
17 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
18 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
19 |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
248
diff
changeset
|
20 |
248
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
21 -- XEP-0082: XMPP Date and Time Profiles |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
22 |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
23 local os_date = os.date; |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
24 local error = error; |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
25 |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
26 module "datetime" |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
27 |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
28 function date() |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
29 return os_date("!%Y-%m-%d"); |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
30 end |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
31 |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
32 function datetime() |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
33 return os_date("!%Y-%m-%dT%H:%M:%SZ"); |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
34 end |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
35 |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
36 function time() |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
37 return os_date("!%H:%M:%S"); |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
38 end |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
39 |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
40 function legacy() |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
41 return os_date("!%Y%m%dT%H:%M:%S"); |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
42 end |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
43 |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
44 function parse(s) |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
45 error("datetime.parse: Not implemented"); -- TODO |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
46 end |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
47 |
8ce9559d501a
Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
48 return _M; |