Annotate

util/datetime.lua @ 248:8ce9559d501a

Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
author Waqas Hussain <waqas20@gmail.com>
date Thu, 13 Nov 2008 12:12:19 +0500
child 519:cccd610a0ef9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
248
8ce9559d501a Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
1 -- 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
2
8ce9559d501a Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
3 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
4 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
5
8ce9559d501a Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
6 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
7
8ce9559d501a Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
8 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
9 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
10 end
8ce9559d501a Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
11
8ce9559d501a Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
12 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
13 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
14 end
8ce9559d501a Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
15
8ce9559d501a Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
16 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
17 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
18 end
8ce9559d501a Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
19
8ce9559d501a Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
20 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
21 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
22 end
8ce9559d501a Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
23
8ce9559d501a Added util.datetime: Utility methods to support XEP-0082: XMPP Date and Time Profiles
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
24 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
25 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
26 end
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 return _M;