124 lines
5.2 KiB
HTML
124 lines
5.2 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<TITLE>ctime(3)</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
<H1>ctime(3)</H1>
|
|
<HR>
|
|
<PRE>
|
|
|
|
</PRE>
|
|
<H2>NAME</H2><PRE>
|
|
ctime, localtime, gmtime, asctime, tzset - convert date and time to
|
|
ASCII
|
|
|
|
|
|
</PRE>
|
|
<H2>SYNOPSIS</H2><PRE>
|
|
<STRONG>#include</STRONG> <STRONG><sys/types.h></STRONG>
|
|
<STRONG>#include</STRONG> <STRONG><time.h></STRONG>
|
|
|
|
<STRONG>void</STRONG> <STRONG>tzset(void)</STRONG>
|
|
<STRONG>char</STRONG> <STRONG>*ctime(const</STRONG> <STRONG>time_t</STRONG> <STRONG>*</STRONG><EM>clock</EM><STRONG>)</STRONG>
|
|
<STRONG>char</STRONG> <STRONG>*asctime(const</STRONG> <STRONG>struct</STRONG> <STRONG>tm</STRONG> <STRONG>*</STRONG><EM>tm</EM><STRONG>)</STRONG>
|
|
<STRONG>struct</STRONG> <STRONG>tm</STRONG> <STRONG>*localtime(const</STRONG> <STRONG>time_t</STRONG> <STRONG>*</STRONG><EM>clock</EM><STRONG>)</STRONG>
|
|
<STRONG>struct</STRONG> <STRONG>tm</STRONG> <STRONG>*gmtime(const</STRONG> <STRONG>time_t</STRONG> <STRONG>*</STRONG><EM>clock</EM><STRONG>)</STRONG>
|
|
|
|
|
|
</PRE>
|
|
<H2>DESCRIPTION</H2><PRE>
|
|
<STRONG>Tzset</STRONG> uses the value of the environment variable <STRONG>TZ</STRONG> to set up the time
|
|
conversion information used by <STRONG>localtime</STRONG>.
|
|
|
|
If <STRONG>TZ</STRONG> does not appear in the environment, the <STRONG>TZDEFAULT</STRONG> file (as defined
|
|
in <<EM>tzfile</EM>.<EM>h</EM>>) is used by <STRONG>localtime</STRONG>. If this file fails for any reason,
|
|
the GMT offset as provided by the kernel is used. In this case, DST is
|
|
ignored, resulting in the time being incorrect by some amount if DST is
|
|
currently in effect. If this fails for any reason, GMT is used.
|
|
|
|
If <STRONG>TZ</STRONG> appears in the environment but its value is a null string,
|
|
Greenwich Mean Time is used; if <STRONG>TZ</STRONG> appears and begins with a slash, it is
|
|
used as the absolute pathname of the <STRONG><A HREF="../man5/tzfile.5.html">tzfile(5)</A></STRONG>-format file from which to
|
|
read the time conversion information; if <STRONG>TZ</STRONG> appears and begins with a
|
|
character other than a slash, it's used as a pathname relative to the
|
|
system time conversion information directory, defined as <STRONG>TZDIR</STRONG> in the
|
|
include file <STRONG>tzfile.h</STRONG>. If this file fails for any reason, the GMT offset
|
|
as provided by the kernel is used, as described above. If this fails for
|
|
any reason, GMT is used. See <STRONG><A HREF="../man5/TZ.5.html">TZ(5)</A></STRONG> for a proper description of the <STRONG>TZ</STRONG>
|
|
variable.
|
|
|
|
<STRONG>Ctime</STRONG> converts a time value, pointed to by <EM>clock</EM>, such as returned by
|
|
<STRONG><A HREF="../man2/time.2.html">time(2)</A></STRONG> into ASCII and returns a pointer to a 26-character string in the
|
|
following form. All the fields have constant width.
|
|
|
|
Sun Sep 16 01:03:52 1973\n\0
|
|
|
|
<STRONG>Localtime</STRONG> and <STRONG>gmtime</STRONG> return pointers to structures containing the broken-
|
|
down time. <STRONG>Localtime</STRONG> corrects for the time zone and possible daylight
|
|
savings time; <STRONG>gmtime</STRONG> converts directly to GMT, which is the time UNIX
|
|
uses. <STRONG>Asctime</STRONG> converts a broken-down time to ASCII and returns a pointer
|
|
to a 26-character string.
|
|
|
|
The structure declaration from the include file is:
|
|
|
|
|
|
struct tm {
|
|
int tm_sec; /* 0-59 seconds */
|
|
int tm_min; /* 0-59 minutes */
|
|
int tm_hour; /* 0-23 hour */
|
|
int tm_mday; /* 1-31 day of month */
|
|
int tm_mon; /* 0-11 month */
|
|
int tm_year; /* 0- year - 1900 */
|
|
int tm_wday; /* 0-6 day of week (Sunday = 0) */
|
|
int tm_yday; /* 0-365 day of year */
|
|
int tm_isdst; /* flag: daylight savings time in effect */
|
|
long tm_gmtoff; /* offset from GMT in seconds */
|
|
char **tm_zone; /* abbreviation of timezone name */
|
|
};
|
|
|
|
<STRONG>Tm_isdst</STRONG> is non-zero if a time zone adjustment such as Daylight Savings
|
|
time is in effect.
|
|
|
|
<STRONG>Tm_gmtoff</STRONG> is the offset (in seconds) of the time represented from GMT,
|
|
with positive values indicating East of Greenwich.
|
|
|
|
|
|
</PRE>
|
|
<H2>FILES</H2><PRE>
|
|
/usr/lib/zoneinfo time zone information directory
|
|
/etc/localtime local time zone file
|
|
|
|
|
|
</PRE>
|
|
<H2>SEE ALSO</H2><PRE>
|
|
<STRONG><A HREF="../man2/time.2.html">time(2)</A></STRONG>, <STRONG><A HREF="../man3/getenv.3.html">getenv(3)</A></STRONG>, <STRONG><A HREF="../man5/tzfile.5.html">tzfile(5)</A></STRONG>, <STRONG><A HREF="../man5/TZ.5.html">TZ(5)</A></STRONG>, <STRONG><A HREF="../man7/environ.7.html">environ(7)</A></STRONG>, <STRONG><A HREF="../man8/zic.8.html">zic(8)</A></STRONG>.
|
|
|
|
|
|
</PRE>
|
|
<H2>NOTE</H2><PRE>
|
|
The return values point to static data whose content is overwritten by
|
|
each call. The <STRONG>tm_zone</STRONG> field of a returned <STRONG>struct</STRONG> <STRONG>tm</STRONG> points to a static
|
|
array of characters, which will also be overwritten at the next call (and
|
|
by calls to <STRONG>tzset</STRONG>).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</PRE>
|
|
</BODY>
|
|
</HTML>
|