# $time(5)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

$time - The current system time

## SYNOPSIS

$time "string"

## DESCRIPTION

$time is a constantly changing variable which is set to the current system time. The format of $time is "`YYYYCCCMMDDWhhmmssSSS`", where:-

YYYY

The current year (full 4 digits so should be millennium bug free).

CCC

Day of the year (0-366).

MM

The month of the year (1-12).

DD

The day of the month (1-31).

W

The day of the week (0-6 Sunday=0).

hh

The hour (0-23).

mm

The minute (0-59).

ss

The second (0-59).

SSS

The millisecond (0-999).

$time can be set to an integer value which is a time offset in seconds, for example if the following was executed;-

    set-variable $time "3600"
    ml-write &cat "$time is " $time
    set-variable $time "0"

The written time would one hour ahead of the system time.

## EXAMPLE

The following macro times the time taken to execute a user command:-

    define-macro time
        !force set-variable #l2 @1
        !if &not $status
            set-variable #l2 @ml00 "Time command"
        !endif
        set-variable #l0 $time
        !force execute-line #l2
        set-variable #l1 $time
        set-variable #l2 &add &mid #l0 16 2 &mul 60 &add &mid #l0 14 2 &mul 60 &mid #l0 12 2
        set-variable #l3 &add &mid #l1 16 2 &mul 60 &add &mid #l1 14 2 &mul 60 &mid #l1 12 2
        !if &les &set #l4 &sub &rig #l1 18 &rig #l0 18 0
            set-variable #l2 &add #l2 1
            set-variable #l4 &add 1000 #l4
        !endif
        ml-write &spr "Command took %d sec %d msec" &sub #l3 #l2 #l4
    !emacro

time(3) is a macro defined in misc.emf.

organizer(3) uses $time to work out the current month.

## SEE ALSO

time(3), organizer(3).

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>