.\" Copyright (c) 1989, 1991 The Regents of the University of California.
.\" This code is derived from software contributed to Berkeley by
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" @(#)ctime.3 6.15 (Berkeley) 4/19/91
.Nd transform binary date and time value to
.Fd #include <sys/types.h>
.Vt extern char *tzname[2];
.Fn ctime "const time_t *clock"
.Fn difftime "time_t time1" "time_t time0"
.Fn asctime "const struct tm *tm"
.Fn localtime "const time_t *clock"
.Fn gmtime "const time_t *clock"
.Fn mktime "struct tm *tm"
all take as an argument a time value representing the time in seconds since
converts the time value pointed at by
and returns a pointer to a
(described below) which contains
the broken-out time information for the value after adjusting for the current
time zone (and any other factors such as Daylight Saving Time).
Time zone adjustments are performed as specified by the
environmental variable (see
to initialize time conversion information if
has not already been called by the process.
After filling in the tm structure,
string that's the time zone abbreviation to be
similarly converts the time value, but without any time zone adjustment,
and returns a pointer to a tm structure (described below).
adjusts the time value for the current time zone in the same manner as
and returns a pointer to a 26-character string of the form:
.Bd -literal -offset indent
Thu Nov 24 18:22:48 1986\en\e0
All the fields have constant width.
converts the broken down time in the structure
shown in the example above.
converts the broken-down time, expressed as local time, in the structure
pointed to by tm into a time value with the same encoding as that of the
function, that is, seconds from the Epoch,
The original values of the
components of the structure are ignored, and the original values of the
other components are not restricted to their normal ranges.
(A positive or zero value for
to presume initially that summer time (for example, Daylight Saving Time)
is or is not in effect for the specified time, respectively.
function to attempt to divine whether summer time is in effect for the
On successful completion, the values of the
components of the structure are set appropriately, and the other components
are set to represent the specified calendar time, but with their values
forced to their normal ranges; the final value of
returns the specified calendar time; if the calendar time cannot be
represented, it returns \-1;
returns the difference between two calendar times,
External declarations as well as the tm structure definition are in the
The tm structure includes at least the following fields:
.Bd -literal -offset indent
int tm_sec; /\(** seconds (0 - 60) \(**/
int tm_min; /\(** minutes (0 - 59) \(**/
int tm_hour; /\(** hours (0 - 23) \(**/
int tm_mday; /\(** day of month (1 - 31) \(**/
int tm_mon; /\(** month of year (0 - 11) \(**/
int tm_year; /\(** year \- 1900 \(**/
int tm_wday; /\(** day of week (Sunday = 0) \(**/
int tm_yday; /\(** day of year (0 - 365) \(**/
int tm_isdst; /\(** is summer time in effect? \(**/
char \(**tm_zone; /\(** abbreviation of timezone name \(**/
long tm_gmtoff; /\(** offset from UTC in seconds \(**/
is non-zero if summer time is in effect.
is the offset (in seconds) of the time represented from
values indicating east of the Prime Meridian.
This manual page is derived from
the time package contributed to Berkeley by
Arthur Olsen and which appeared in
these functions leaves their result in an internal static object and return
a pointer to that object. Subsequent calls to these
function will modify the same object.
field of a returned tm structure points to a static array of characters,
which will also be overwritten by any subsequent calls (as well as by
Use of the external variable
entry in the tm structure is preferred.
Avoid using out-of-range values with
when setting up lunch with promptness sticklers in Riyadh.