Script Command: TIME


TIME [-ef:s]

Print the current time of day or compute elapsed time in milliseconds. With no options, a HH:MM:SS time string is printed.

Options:

-eprint elapsed time since last stamp.

-f <}>print formatted time/date string (see below).

-qquiet mode (TIME variable is updated, but all console output is turned off).

-sstamp the current time.

Format...

%a: abbreviated weekday name

%A: full weekday name

%b: abbreviated month name

%B: full month name

%c: date and time representation appropriate for locale

%d: day of month as decimal number (01-31)

%H: hour in 24-hour format (00-23)

%I: hour in 12-hour format (01-12)

%j: day of year as decimal number (001-366)

%m: month as decimal number (01-12)

%M: minute as decimal number (00-59)

%p: current locale's AM/PM indicator for 12-hour clock

%S: second as decimal number (00-59)

%U: week of year as decimal number, with Sunday as first day of week (00-51).

%w: weekday as decimal number (0-6; Sunday=0)

%W: week of year as decimal number, with Monday as first day of week (00-51).

%x: date representation of current locale

%X: time representation for current locale

%y: year without centure, as decimal number (00-99)

%Y: year with century, as decimal number

%z: time-zone name or abbreviation; no chars if time zone is unknown

%Z: all-caps version of %z

EXAMPLES:

# display 01/26/06 10:25:05

TIME -f\%c

# display Started on Thursday January 26, 2006 at 10:27:26

TIME -f "Started on \%A \%B \%d, \%Y at \%I:\%M:\%S"

EXAMPLE SCRIPT:

This script will do "something" at the top of every hour...

# TOP:

TIME -qf %M

set LASTTIME $TIME

# Every 10 seconds wake up and see if the minute has changed.

# If it has, then see if it changed to 0. If it has, then we

# assume we've just passed the top of the hour...

#

# LOOP:

SLEEP 10000

TIME -qf %M

if $TIME ne $LASTTIME goto NEW_MINUTE

goto LOOP

# NEW_MINUTE:

set LASTTIME $TIME

echo New minute: $TIME

if $TIME eq 0 goto TOP_OF_THE_HOUR

goto LOOP

# TOP_OF_THE_HOUR:

echo HEY, its the top of the hour!!!

goto LOOP

* Note_1: this command will populate the shell variable "TIME" with the result.

* Note_2: uCon's script runner supports symbols (refer to scripting overview), which are similar to shell variables but are preceded by a '%' instead of a '$'. So, since '%' is used as a delimiter in the format script, if SYMFILE is set (meaning that symbols are being used) the '%' sign should be preceded by a backslash so that uCon knows not to parse this as a symbol name. Refer to the SYMBOLS section of the SCRIPT help text for more info on symbols.