Sophie

Sophie

distrib > Mandriva > 8.1 > i586 > by-pkgid > 700475c8ae73fb4d57b6df4485c29e1c > files > 207

slang-doc-1.4.4-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
 <TITLE> S-Lang Run-Time Library Reference: Version 1.4.0: Time and Date Functions</TITLE>
 <LINK HREF="slangfun-9.html" REL=next>
 <LINK HREF="slangfun-7.html" REL=previous>
 <LINK HREF="slangfun.html#toc8" REL=contents>
</HEAD>
<BODY>
<A HREF="slangfun-9.html">Next</A>
<A HREF="slangfun-7.html">Previous</A>
<A HREF="slangfun.html#toc8">Contents</A>
<HR>
<H2><A NAME="s8">8. Time and Date Functions</A></H2>

<P>
<H2><A NAME="_time"></A> <A NAME="ss8.1">8.1 <B>_time</B></A>
</H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Get the current time in seconds
<DT><B> Usage </B><DD><P><CODE>ULong_Type _time ()</CODE>
<DT><B> Description </B><DD><P>The <CODE>_time</CODE> function returns the number of elapsed seconds since
00:00:00 GMT, January 1, 1970.  The <CODE>ctime</CODE> function may be used
to convert this into a string representation.
<DT><B> See Also </B><DD><P><CODE>ctime, time, localtime, gmtime</CODE>
</DL>
<P>
<P>
<H2><A NAME="ctime"></A> <A NAME="ss8.2">8.2 <B>ctime</B></A>
</H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Convert a calendar time to a string
<DT><B> Usage </B><DD><P><CODE>String_Type ctime(ULong_Type secs)</CODE>
<DT><B> Description </B><DD><P>This function returns a string representation of the time as given
by <CODE>secs</CODE> seconds since 1970.
<DT><B> See Also </B><DD><P><CODE>time, _time, localtime, gmtime</CODE>
</DL>
<P>
<P>
<H2><A NAME="gmtime"></A> <A NAME="ss8.3">8.3 <B>gmtime</B></A>
</H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Break down a time in seconds to GMT timezone
<DT><B> Usage </B><DD><P><CODE>Struct_Type gmtime (Long_Type secs)</CODE>
<DT><B> Description </B><DD><P>The <CODE>gmtime</CODE> function is exactly like <CODE>localtime</CODE> except
that the values in the structure it returns are with respect to GMT
instead of the local timezone.  See the documentation for
<CODE>localtime</CODE> for more information.
<DT><B> Notes </B><DD><P>On systems that do not support the <CODE>gmtime</CODE> C library function,
this function is the same as <CODE>localtime</CODE>.
<DT><B> See Also </B><DD><P><CODE>localtime, _time</CODE>
</DL>
<P>
<P>
<H2><A NAME="localtime"></A> <A NAME="ss8.4">8.4 <B>localtime</B></A>
</H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Break down a time in seconds to local timezone
<DT><B> Usage </B><DD><P><CODE>Struct_Type localtime (Long_Type secs)</CODE>
<DT><B> Description </B><DD><P>The <CODE>localtime</CODE> function takes a parameter <CODE>secs</CODE>
representing the number of seconds since 00:00:00, January 1 1970
UTC and returns a structure containing information about <CODE>secs</CODE>
in the local timezone.  The structure contains the following
<CODE>Int_Type</CODE> fields:
<P><CODE>tm_sec</CODE> The number of seconds after the minute, normally
in the range 0 to 59, but can be up to 61 to allow for
leap seconds.
<P><CODE>tm_min</CODE> The number of minutes after the hour, in the
range 0 to 59.
<P><CODE>tm_hour</CODE> The number of hours past midnight, in the range
0 to 23.
<P><CODE>tm_mday</CODE> The day of the month, in the range 1 to 31.
<P><CODE>tm_mon</CODE> The number of months since January, in the range
0 to 11.
<P><CODE>tm_year</CODE> The number of years since 1900.
<P><CODE>tm_wday</CODE> The number of days since Sunday, in the range 0
to 6.
<P><CODE>tm_yday</CODE> The number of days since January 1, in the
range 0 to 365.
<P><CODE>tm_isdst</CODE> 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.
<DT><B> See Also </B><DD><P><CODE>gmtime, _time, ctime</CODE>
</DL>
<P>
<P>
<H2><A NAME="tic"></A> <A NAME="ss8.5">8.5 <B>tic</B></A>
</H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Start timing
<DT><B> Usage </B><DD><P><CODE>void tic ()</CODE>
<DT><B> Description </B><DD><P>The <CODE>tic</CODE> function restarts the internal clock used for timing
the execution of commands.  To get the elapsed time of the clock,
use the <CODE>toc</CODE> function.
<DT><B> See Also </B><DD><P><CODE>toc, times</CODE>
</DL>
<P>
<P>
<H2><A NAME="time"></A> <A NAME="ss8.6">8.6 <B>time</B></A>
</H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Return the current data and time as a string
<DT><B> Usage </B><DD><P><CODE>String_Type time ()</CODE>
<DT><B> Description </B><DD><P>This function returns the current time as a string of the form:
<BLOCKQUOTE><CODE>
<PRE>
    Sun Apr 21 13:34:17 1996
</PRE>
</CODE></BLOCKQUOTE>
<DT><B> See Also </B><DD><P><CODE>ctime, message, substr</CODE>
</DL>
<P>
<P>
<H2><A NAME="times"></A> <A NAME="ss8.7">8.7 <B>times</B></A>
</H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Get process times
<DT><B> Usage </B><DD><P><CODE>Struct_Type times ()</CODE>
<DT><B> Description </B><DD><P>The <CODE>times</CODE> function returns a structure containing the
following fields:
<BLOCKQUOTE><CODE>
<PRE>
    tms_utime     (user time)
    tms_stime     (system time)
    tms_cutime    (user time of child processes)
    tms_cstime    (system time of child processes)
</PRE>
</CODE></BLOCKQUOTE>
<DT><B> Notes </B><DD><P>Not all systems support this function.
<DT><B> See Also </B><DD><P><CODE>tic, toc, _times</CODE>
</DL>
<P>
<P>
<H2><A NAME="toc"></A> <A NAME="ss8.8">8.8 <B>toc</B></A>
</H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Get elapsed CPU time
<DT><B> Usage </B><DD><P><CODE>Double_Type toc ()</CODE>
<DT><B> Description </B><DD><P>The <CODE>toc</CODE> function returns the elapsed CPU time in seconds since
the last call to <CODE>tic</CODE>.  The CPU time is the amount of time the
CPU spent running the code of the current process.
<DT><B> Example </B><DD><P>The <CODE>tic</CODE> and <CODE>toc</CODE> functions are ideal for timing the
execution of the interpreter:
<BLOCKQUOTE><CODE>
<PRE>
     variable a = "hello", b = "world", c, n = 100000, t;
     
     tic ();  loop (n) c = a + b; t = toc ();
     vmessage ("a+b took %f seconds\n", t);
     tic ();  loop (n) c = strcat(a,b); t = toc ();
     vmessage ("strcat took %f seconds\n", t);
</PRE>
</CODE></BLOCKQUOTE>
<DT><B> Notes </B><DD><P>This function may not be available on all systems.
<P>The implementation of this function is based upon the <CODE>times</CODE>
system call.  The precision of the clock is system dependent.
<DT><B> See Also </B><DD><P><CODE>tic, times, _time</CODE>
</DL>
<P>
<P>
<P>
<HR>
<A HREF="slangfun-9.html">Next</A>
<A HREF="slangfun-7.html">Previous</A>
<A HREF="slangfun.html#toc8">Contents</A>
</BODY>
</HTML>