BSD 4_4 development
[unix-history] / usr / share / man / cat3 / asctime.0
CTIME(3) BSD Programmer's Manual CTIME(3)
N\bNA\bAM\bME\bE
a\bas\bsc\bct\bti\bim\bme\be, c\bct\bti\bim\bme\be, d\bdi\bif\bff\bft\bti\bim\bme\be, g\bgm\bmt\bti\bim\bme\be, l\blo\boc\bca\bal\blt\bti\bim\bme\be, m\bmk\bkt\bti\bim\bme\be - transform binary
date and time value to ASCII
S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
#\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/t\bty\byp\bpe\bes\bs.\b.h\bh>\b>
#\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<t\bti\bim\bme\be.\b.h\bh>\b>
_\be_\bx_\bt_\be_\br_\bn _\bc_\bh_\ba_\br _\b*_\bt_\bz_\bn_\ba_\bm_\be_\b[_\b2_\b]_\b;
_\bc_\bh_\ba_\br _\b*
c\bct\bti\bim\bme\be(_\bc_\bo_\bn_\bs_\bt _\bt_\bi_\bm_\be_\b__\bt _\b*_\bc_\bl_\bo_\bc_\bk);
_\bd_\bo_\bu_\bb_\bl_\be
d\bdi\bif\bff\bft\bti\bim\bme\be(_\bt_\bi_\bm_\be_\b__\bt _\bt_\bi_\bm_\be_\b1, _\bt_\bi_\bm_\be_\b__\bt _\bt_\bi_\bm_\be_\b0);
_\bc_\bh_\ba_\br _\b*
a\bas\bsc\bct\bti\bim\bme\be(_\bc_\bo_\bn_\bs_\bt _\bs_\bt_\br_\bu_\bc_\bt _\bt_\bm _\b*_\bt_\bm);
_\bs_\bt_\br_\bu_\bc_\bt _\bt_\bm _\b*
l\blo\boc\bca\bal\blt\bti\bim\bme\be(_\bc_\bo_\bn_\bs_\bt _\bt_\bi_\bm_\be_\b__\bt _\b*_\bc_\bl_\bo_\bc_\bk);
_\bs_\bt_\br_\bu_\bc_\bt _\bt_\bm _\b*
g\bgm\bmt\bti\bim\bme\be(_\bc_\bo_\bn_\bs_\bt _\bt_\bi_\bm_\be_\b__\bt _\b*_\bc_\bl_\bo_\bc_\bk);
_\bt_\bi_\bm_\be_\b__\bt
m\bmk\bkt\bti\bim\bme\be(_\bs_\bt_\br_\bu_\bc_\bt _\bt_\bm _\b*_\bt_\bm);
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
The functions c\bct\bti\bim\bme\be(), g\bgm\bmt\bti\bim\bme\be() and l\blo\boc\bca\bal\blt\bti\bim\bme\be() all take as an argument a
time value representing the time in seconds since the Epoch (00:00:00
UTC, January 1, 1970; see time(3)).
The function l\blo\boc\bca\bal\blt\bti\bim\bme\be() converts the time value pointed at by _\bc_\bl_\bo_\bc_\bk, and
returns a pointer to a ``_\bs_\bt_\br_\bu_\bc_\bt _\bt_\bm'' (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 TZ environmental vari-
able (see tzset(3)). The function l\blo\boc\bca\bal\blt\bti\bim\bme\be() uses tzset to initialize
time conversion information if tzset has not already been called by the
process.
After filling in the tm structure, l\blo\boc\bca\bal\blt\bti\bim\bme\be() sets the _\bt_\bm_\b__\bi_\bs_\bd_\bs_\bt'th ele-
ment of _\bt_\bz_\bn_\ba_\bm_\be to a pointer to an ASCII string that's the time zone ab-
breviation to be used with l\blo\boc\bca\bal\blt\bti\bim\bme\be()'s return value.
The function g\bgm\bmt\bti\bim\bme\be() similarly converts the time value, but without any
time zone adjustment, and returns a pointer to a tm structure (described
below).
The c\bct\bti\bim\bme\be() function adjusts the time value for the current time zone in
the same manner as l\blo\boc\bca\bal\blt\bti\bim\bme\be(), and returns a pointer to a 26-character
string of the form:
Thu Nov 24 18:22:48 1986\n\0
All the fields have constant width.
The a\bas\bsc\bct\bti\bim\bme\be() function converts the broken down time in the structure _\bt_\bm
pointed at by _\b*_\bt_\bm to the form shown in the example above.
The function m\bmk\bkt\bti\bim\bme\be() 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 values returned by the time(3) function, that is,
seconds from the Epoch, UTC.
The original values of the _\bt_\bm_\b__\bw_\bd_\ba_\by and _\bt_\bm_\b__\by_\bd_\ba_\by components of the struc-
ture are ignored, and the original values of the other components are not
restricted to their normal ranges. (A positive or zero value for
_\bt_\bm_\b__\bi_\bs_\bd_\bs_\bt causes m\bmk\bkt\bti\bim\bme\be() to presume initially that summer time (for exam-
ple, Daylight Saving Time) is or is not in effect for the specified time,
respectively. A negative value for _\bt_\bm_\b__\bi_\bs_\bd_\bs_\bt causes the m\bmk\bkt\bti\bim\bme\be() function
to attempt to divine whether summer time is in effect for the specified
time.)
On successful completion, the values of the _\bt_\bm_\b__\bw_\bd_\ba_\by and _\bt_\bm_\b__\by_\bd_\ba_\by compo-
nents 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 _\bt_\bm_\b__\bm_\bd_\ba_\by is not set un-
til _\bt_\bm_\b__\bm_\bo_\bn and _\bt_\bm_\b__\by_\be_\ba_\br are determined. M\bMk\bkt\bti\bim\bme\be() returns the specified
calendar time; if the calendar time cannot be represented, it returns -1;
The d\bdi\bif\bff\bft\bti\bim\bme\be() function returns the difference between two calendar
times, (_\bt_\bi_\bm_\be_\b1 - _\bt_\bi_\bm_\be_\b0), expressed in seconds.
External declarations as well as the tm structure definition are in the
<_\bt_\bi_\bm_\be_\b._\bh> include file. The tm structure includes at least the following
fields:
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 */
The field _\bt_\bm_\b__\bi_\bs_\bd_\bs_\bt is non-zero if summer time is in effect.
The field _\bt_\bm_\b__\bg_\bm_\bt_\bo_\bf_\bf is the offset (in seconds) of the time represented
from UTC, with positive values indicating east of the Prime Meridian.
S\bSE\bEE\bE A\bAL\bLS\bSO\bO
date(1), gettimeofday(2), getenv(3), time(3), tzset(3), tzfile(5)
H\bHI\bIS\bST\bTO\bOR\bRY\bY
This manual page is derived from the time package contributed to Berkeley
by Arthur Olsen and which appeared in 4.3BSD.
B\bBU\bUG\bGS\bS
Except for d\bdi\bif\bff\bft\bti\bim\bme\be() and m\bmk\bkt\bti\bim\bme\be(), these functions leaves their result
in an internal static object and return a pointer to that object. Subse-
quent calls to these function will modify the same object.
The _\bt_\bm_\b__\bz_\bo_\bn_\be 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 subsequent calls to tzset(3) and tzsetwall(3)).
Use of the external variable _\bt_\bz_\bn_\ba_\bm_\be is discouraged; the _\bt_\bm_\b__\bz_\bo_\bn_\be entry in
the tm structure is preferred.
Avoid using out-of-range values with m\bmk\bkt\bti\bim\bme\be() when setting up lunch with
promptness sticklers in Riyadh.
4.3 Berkeley Distribution June 4, 1993 2