Previous Topic: $SERVER()Next Topic: $TIMER()


$TIME()

This function obtains the current time of day (TOD) clock value, adds and subtracts double-word unsigned binary values, and converts CPU timer values to printable strings.

Syntax

Form 1:

$TIME(ADD,value1,value2)

Form 2:

$TIME(FULL,value1)

Form 3:

$TIME(FULLB,value1)

Form 4:

$TIME(SEC,value1)

Form 5:

$TIME(STCK)

Form 6:

$TIME(SUB,value1,value2)

Parameters

ADD

Adds value1 to value2. The result is an unsigned 8-byte binary value in IBM TOD clock format.

SUB

Subtracts value2 from value1. The result is an unsigned 8-byte binary value in IBM TOD clock format.

value1

8-byte binary string in the IBM TOD clock format.

value2

8-byte binary string in the IBM TOD clock format to be added to or subtracted from value1.

FULL

Converts value1 to a printable string in the format hh:mm:ss.tho (hh is hours, mm is minutes, ss is seconds, and tho is thousandths of a second). The string is always 12 bytes in length and all leading zeros and field separators are present.

FULLB

Same as FULL, except that blanks replace leading zeros and punctuation.

SEC

Converts value1 to seconds. The returned number is in REXX format, contains a decimal point, and is accurate to thousandths of a second.

STCK

Returns the current value of the system TOD clock as an 8-byte unsigned binary value.

Return Codes

101 - 103

ARG n MISSING OR INVALID

Example 1

/*  Report total CPU usage for an address space */

parse arg ascb                  /* address of ASCB is passed          */
cpu = memory('f',ascb+64,8)     /* get elapsed jobstep time (ASCBEJST */
string = $time('full',cpu)      /* convert to printable string        */
return string

Example 2

/*  Determine elapsed CPU time for subroutine  */

start = cpu('stck')             /* obtain start CPU value         */
call test_sub                   /* invoke subroutine to time      */
stop = cpu('stck')              /* obtain ending CPU value        */
total = $time('sub',stop,start) /* determine elapsed CPU time     */
string = $time('fullb',total)   /* make printable. no lead zeros. */
say 'Subroutine CPU: ' string