uCon HomePage
Script Cmd: TIME
TIME [-ef:qrs] [hires-on | hires-off]
Print the current time of day or compute elapsed time in milliseconds. With no options, a HH:MM:SS time string is printed.
Options:
-e print elapsed time since last stamp (used with -s)
-f {format} print formatted time/date string (see below).
-q quiet mode (TIME variable is updated, but all console output is turned off).
-r display best-case-achievable timer resolution in milliseconds
-s stamp the current time (used with -e).
Subcommands (see notes 2&3 below):
hires-on:
enable uCon's use of a higher
resolution system timer (more CPU intense)
hires-off:
disable the use of the higher resolution system timer (more efficient, but less accurate)
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
- New as of Aug 2022: see note 3 below.
EXAMPLE1:
# 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"
EXAMPLE2:
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.
* Note_3: as of Aug 2022, you can append ":msec" to any of the -f formats and the milliseconds will be appended to the timestamp.