12.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($year,month,day,hour,min,sec,<timezone>$)
The time.fromCalendar($year,month,day,hour,min,sec,<timezone>$) 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($t$)
The time.fromJD($t$) function creates a date object from the specified numerical Julian date.

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

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

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

time.intervalStr($t_2,t_1,format$)
The time.intervalStr($t_2,t_1,format$) 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($t$)
The time.sleep($t$) function sleeps for $t$ seconds, or for time period $t$ if it has dimensions of time.

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

time.string($t,<format>,<timezone>$)
The time.string($t,<format>,<timezone>$) function returns a string representation of the specified date object $t$. 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.