HP-UX Reference (11i v3 07/02) - 3 Library Functions A-M (vol 6)

c
ctime(3C) ctime(3C)
If the value of the timezone cannot be determined using the environment variable
TZ or
the file
/etc/default/tz
, it is set to the default value of EST5EDT. If the
timezone is set to the default value of EST5EDT and the timezone adjustment file is not
available, the timezone is set to a default value of UTC (Coordinated Universal Time).
/etc/default/tz
can be modified for an appropriate default value for timezone.
The
<time.h> header file contains declarations of all relevant functions and externals. It also contains
the tm structure, which includes the following members:
int tm_sec; /* seconds after the minute - [0,61] */
int tm_min; /* minutes after the hour - [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; /* years since 1900 */
int tm_wday; /* days since Sunday - [0,6] */
int tm_yday; /* days since January 1 - [0,365] */
int tm_isdst; /* daylight savings time flag */
The value of tm_isdst is positive if a summer time zone adjustment such as Daylight Savings Time is in
effect, zero if not in effect, and negative if the information is not available.
The external variable timezone contains the difference, in seconds, between UTC and local standard
time (for example, in the U.S. Eastern time zone (EST), timezone is 5*60*60). The external variable
daylight is non-zero only if a summer time zone adjustment is specified in the
TZ environment variable.
The external variable
tzname[2] contains the local standard and local summer time zone abbreviations
as specified by the TZ environment variable.
EXTERNAL INFLUENCES
Locale
The LC_CTYPE category determines the interpretation of the bytes within format as single and/or multi-
byte characters.
Environment Variables
The
tzset() function uses the contents of TZ to set the values of the external variables timezone
,
daylight, and tzname. TZ also determines the time zone name substituted for the %Z and
%z direc-
tives and the time zone adjustments performed by
localtime() , mktime(), and ctime().Two
methods for specifying a time zone within TZ are described in environ(5).
International Code Set Support
Single and multibyte character code sets are supported.
RETURN VALUE
For asctime_r() and ctime_r(), if the buffer is of insufficient length, a NULL is returned and errno
set to [EINVAL].
asctime_r() , ctime_r(), gmtime_r() , and localtime_r()
return a NULL and set errno to
[EINVAL] if NULL pointers are passed in as arguments.
A NULL is returned and errno is set to [ERANGE] if the input to the following routines is not within the
supported range:
asctime(), asctime_r() , ctime(), ctime_r(), gmtime(), gmtime_r() ,
localtime() , localtime_r().
APPLICATION USAGE
The return values for asctime(), ctime(), gmtime(), and localtime() point to static data
whose contents is overwritten by each call.
WARNINGS
Users of asctime_r() , ctime_r(), gmtime_r() , and localtime_r() should also note that
these functions now conform to POSIX.1c. The old prototypes of these functions are supported for compati-
bility with existing DCE applications only.
The range of tm_sec([0,61]) extends to 61 to allow for the occasional one or two leap seconds. How-
ever, the ‘‘seconds since the Epoch’’ value returned by time() and passed as the timer argument does not
include accumulated leap seconds. The tm structure generated by localtime() and gmtime() will
HP-UX 11i Version 3: February 2007 3 Hewlett-Packard Company 239