## 2.10 The `time` module

The `time` module contains functions for handling objects of type `date`. For more information about manipulating times and dates in Pyxplot, see Section 4.11. Many of the functions below take an optional timezone string as their final argument. This should be specified in the form `Europe/London`, `America/New_York` or `Australia/Perth`, as used by the `tz database`. A complete list of available timezones can be found here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones. If universal time is used, the timezone may be specified as `UTC`.

time.fromCalendar()
The time.fromCalendar() function creates a date object from the specified calendar date. See also the `set calendar` and `set timezone` commands to change the current calendar and timezone.

time.fromJD()
The time.fromJD() function creates a date object from the specified numerical Julian date.

time.fromMJD()
The time.fromMJD() function creates a date object from the specified numerical modified Julian date.

time.fromUnix()
The time.fromUnix() function creates a date object from the specified numerical Unix time.

time.interval()
The time.interval() function returns the numerical time interval between date objects and , with physical units of time.

time.intervalStr()
The time.intervalStr() function returns a string representation of the time interval elapsed between the first and second supplied date objects. The third input is used to control the format of the output, with the following tokens being substituted for:

Token | Value
--- | ---
`%%` | A literal % sign.
`%d` | The number of days elapsed, modulo 365.
`%D` | The number of days elapsed.
`%h` | The number of hours elapsed, modulo 24.
`%H` | The number of hours elapsed.
`%m` | The number of minutes elapsed, modulo 60.
`%M` | The number of minutes elapsed.
`%s` | The number of seconds elapsed, modulo 60.
`%S` | The number of seconds elapsed.
`%Y` | The number of years elapsed.

time.now()
The time.now() function creates a date object representing the current time.

time.sleep()
The time.sleep() function sleeps for seconds, or for time period if it has dimensions of time.

time.sleepUntil()
The time.sleepUntil() function sleeps until the specified date and time. Its argument should be a date object.

time.string()
The time.string() function returns a string representation of the specified date object . The second input is optional, and may be used to control the format of the output. If no format string is provided, then the format
`"%a %Y %b %d %H:%M:%S"`
is used. In such format strings, the following tokens are substituted for various parts of the date:

Token | Value
--- | ---
`%%` | A literal % sign.
`%a` | Three-letter abbreviated weekday name.
`%A` | Full weekday name.
`%b` | Three-letter abbreviated month name.
`%B` | Full month name.
`%C` | Century number, e.g. 21 for the years 2000-2100.
`%d` | Day of month.
`%H` | Hour of day, in range 00-23.
`%I` | Hour of day, in range 01-12.
`%k` | Hour of day, in range 0-23.
`%l` | Hour of day, in range 1-12.
`%m` | Month number, in range 01-12.
`%M` | Minute, in range 00-59.
`%p` | Either `am` or `pm`.
`%S` | Second, in range 00-59.
`%y` | Last two digits of year number.
`%Y` | Year number.