util.datetime

Provides utility functions for retrieving the current or specified time in the formats specified by XEP-0082.

Using

   local datetime = require "util.datetime";

Reference

In all cases, t is a Lua time value, as returned by os.time(). On most systems this is stored as the number of seconds since midnight 1970-01-01.

When t is not specified, the current time is used.

datetime.date(t)

Returns the time t (or the current time if t is nil or not given) in the format given by the 'Date' profile of XEP-0082.

An example return value is:

2009-03-29

datetime.datetime(t)

Returns the time t (or the current time if t is nil or not given) in the format given by the 'DateTime' profile of XEP-0082.

An example return value is:

2009-03-29T00:33:50Z

datetime.time(t)

Returns the time t (or the current time if t is nil or not given) in the format given by the 'Time' profile of XEP-0082.

An example return value is:

14:34:47

datetime.legacy(t)

Returns the time t (or the current time if t is nil or not given) in the format given by the deprecated XEP-0091: Legacy Delayed Delivery

An example return value is:

20020910T23:08:25

datetime.parse(s)

Parses the timestamp s from the format given by the 'DateTime' profile of XEP-0082 and returns it as an integer.

An example:

datetime.parse("2009-03-29T00:33:50Z") --> 1238286830