Convert a calendar time to a string
String_Type ctime(Long_Type secs)
This function returns a string representation of the time as given
secs seconds since 00:00:00 UTC, Jan 1, 1970.
time, strftime, _time, localtime, gmtime
Break down a time in seconds to the GMT timezone
Struct_Type gmtime (Long_Type secs)
gmtime function is exactly like
that the values in the structure it returns are with respect to GMT
instead of the local timezone. See the documentation for
localtime for more information.
On systems that do not support the
gmtime C library function,
this function is the same as
localtime, _time, mktime
Break down a time in seconds to the local timezone
Struct_Type localtime (Long_Type secs)
localtime function takes a parameter
representing the number of seconds since 00:00:00, January 1 1970
UTC and returns a structure containing information about
in the local timezone. The structure contains the following
tm_sec The number of seconds after the minute, normally
in the range 0 to 59, but can be up to 61 to allow for
tm_min The number of minutes after the hour, in the
range 0 to 59.
tm_hour The number of hours past midnight, in the range
0 to 23.
tm_mday The day of the month, in the range 1 to 31.
tm_mon The number of months since January, in the range
0 to 11.
tm_year The number of years since 1900.
tm_wday The number of days since Sunday, in the range 0
tm_yday The number of days since January 1, in the
range 0 to 365.
tm_isdst A flag that indicates whether daylight saving
time is in effect at the time described. The value is
positive if daylight saving time is in effect, zero if it
is not, and negative if the information is not available.
gmtime, _time, ctime, mktime
Convert a time-structure to seconds
secs = mktime (Struct_Type tm)
mktime function is essentially the inverse of the
localtime function. See the documentation for that function
for more details.
localtime, gmtime, _time
Format a date and time string
str = strftime (String_Type format [,Struct_Type tm])
strftime creates a date and time string according to a
specified format. If called with a single argument, the current
local time will be used as the reference time. If called with two
arguments, the second argument specifies the reference time, and
must be a structure with the same fields as the structure returned
The format string may be composed of one or more of the following format descriptors:
as well as any others provided by the C library. The actual values represented by the format descriptors are locale-dependent.
%A full weekday name (Monday) %a abbreviated weekday name (Mon) %B full month name (January) %b abbreviated month name (Jan) %c standard date and time representation %d day-of-month (01-31) %H hour (24 hour clock) (00-23) %I hour (12 hour clock) (01-12) %j day-of-year (001-366) %M minute (00-59) %m month (01-12) %p local equivalent of AM or PM %S second (00-59) %U week-of-year, first day Sunday (00-53) %W week-of-year, first day Monday (00-53) %w weekday (0-6, Sunday is 0) %X standard time representation %x standard date representation %Y year with century %y year without century (00-99) %Z timezone name %% percent sign
message (strftime ("Today is %A, day %j of the year")); tm = localtime (0); message (strftime ("Unix time 0 was on a %A", tm));
Reset the CPU timer
_tic function resets the internal CPU timer. The
_toc may be used to read this timer. See the documentation
_toc function for more information.
_toc, times, tic, toc
Reset the interval timer
void tic ()
tic function resets the internal interval timer. The
toc may be used to read the interval timer.
The tic/toc functions may be used to measure execution times. For example, at the slsh prompt, they may be used to measure the speed of a loop:
slsh> tic; loop (500000); toc; 0.06558
On Unix, this timer makes use of the C library
toc, _toc, _tic, times
Get the current calendar time in seconds
Long_Type _time ()
_time function returns the number of elapsed seconds since
00:00:00 UTC, January 1, 1970. A number of functions (
localtime, etc.) are able to convert such a
value to other representations.
ctime, time, localtime, gmtime
Return the current date and time as a string
String_Type time ()
This function returns the current time as a string of the form:
Sun Apr 21 13:34:17 1996
strftime, ctime, message, substr
Convert a time structure for the GMT timezone to seconds
Long_Type secs = timegm(Struct_Type tm)
timegm is the inverse of the
gmtime, mktime, localtime
Get process times
Struct_Type times ()
times function returns a structure containing the
tms_utime (user time) tms_stime (system time) tms_cutime (user time of child processes) tms_cstime (system time of child processes)
Not all systems support this function.
_tic, _toc, _time
Get the elapsed CPU time for the current process
Double_Type _toc ()
_toc function returns the elapsed CPU time in seconds since
the last call to
_tic. The CPU time is the amount of time the
CPU spent running the code of the current process.
This function may not be available on all systems.
The implementation of this function is based upon the
system call. The precision of the clock is system dependent and may
not be very accurate for small time intervals. For this reason, the
tic/toc functions may be more useful for small time-intervals.
_tic, tic, toc, times, _time
Read the interval timer
Double_Type toc ()
toc function returns the elapsed time in seconds since
the last call to
tic. See the documentation for the
tic function for more information.
tic, _tic, _toc, times, _time