|
|
researchv10 Dan Cross
.TH CTIME 3
.CT 2 data_man time_man
.SH NAME
ctime, localtime, gmtime, asctime, timezone \(mi convert date and time to ASCII
.SH SYNOPSIS
.B #include <time.h>
.PP
.nf
.B char *ctime(clock)
.B long *clock;
.PP
.B struct tm *localtime(clock)
.B long *clock;
.PP
.B struct tm *gmtime(clock)
.B long *clock;
.PP
.B char *asctime(tm)
.B struct tm *tm;
.PP
.B char *timezone(zone, dst)
.fi
.SH DESCRIPTION
.I Ctime
converts a time pointed to by
.I clock
such as returned by
.IR time (2)
into ASCII
and returns a pointer to a
26-character string
in the following form.
All the fields have constant width.
.PP
.L
Sun Sep 16 01:03:52 1973\en\e0
.PP
.I Localtime
and
.I gmtime
return pointers to structures containing
the broken-down time.
.I Localtime
corrects for the time zone and possible daylight savings time;
.I gmtime
converts directly to GMT, which is the time UNIX uses.
.I Asctime
converts a broken-down time to ASCII and returns a pointer
to a 26-character string.
.LP
.ta 8n +16n
.nf
\fLstruct tm {
\fLint tm_sec;\fR seconds (range 0..59)
\fLint tm_min;\fP minutes (0..59)
\fLint tm_hour;\fP hours (0..23)
\fLint tm_mday;\fP day of the month (1..31)
\fLint tm_mon;\fP month of the year (0..11)
\fLint tm_year;\fP year A.D. \- 1900
\fLint tm_wday;\fP day of week (0..6, Sunday = 0)
\fLint tm_yday;\fP day of year (0..365)
\fLint tm_isdst;\fP zero means normal time, nonzero means daylight saving time
\fL};\fR
.fi
.PP
When local time is called for,
the program consults the system to determine the time zone and
whether the standard U.S.A. daylight saving time adjustment is
appropriate.
The peculiarities of this conversion
are read from the file
.FR /lib/dst ,
which contains lines of the form
.IP
y0 y1 bday boff eday eoff
.LP
meaning that for years between
.I y0
and
.IR y1 ,
daylight saving time begins (ends)
.IR boff
.RI ( eoff )
days after the Sunday
immediately following
day
.IR bday
.RI ( eday )
of the year.
.PP
.I Timezone
returns the name of the time zone associated with its first argument,
which is measured in minutes westward from Greenwich.
If the second argument is 0, the standard name is used,
otherwise the Daylight Saving version.
If the required name does not appear in a table
built into the routine,
the difference from GMT is produced.
Thus, as Afghanistan is 4:30 ahead of GMT,
.L
timezone(-(60*4+30),\ 0) \fRreturns\fL "GMT+4:30"\fR.
.SH "SEE ALSO"
.IR time (2),
.IR timec (3)
.SH BUGS
The return values point to static data
whose content is overwritten by each call.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.