CTIME(3C) — HP-UX
NAME
ctime, nl_ctime, localtime, gmtime, asctime, nl_asctime, timezone, daylight, tzname, tzset − convert date and time to string
SYNOPSIS
#include <time.h>
char ∗ctime (clock)
long ∗clock;
char ∗nl_ctime (clock, format, langid)
long ∗clock; char ∗format; int langid;
struct tm ∗localtime (clock)
long ∗clock;
struct tm ∗gmtime (clock)
long ∗clock;
char ∗asctime (tm)
struct tm ∗tm;
char ∗nl_asctime (tm, format, langid)
struct tm ∗tm; char ∗format; int
extern long timezone;
extern int daylight;
extern char ∗tzname[2];
void tzset ( )
DESCRIPTION
Ctime converts a long integer, pointed to by clock, representing the time in seconds since 00:00:00 GMT, January 1, 1970, 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
Nl_ctime extends the capabilities of ctime in two ways. First the format specification allows the date and time to be output in a variety of ways. Format uses the field descriptors defined in date(1). If the format is the null string, the D_T_FMT string defined by langinfo(3C) is used. Second langid provides month and weekday names (when selected as alphabetic by the format string) to be in the user’s native language.
Localtime and gmtime return pointers to “tm” structures, described below. Localtime corrects for the time zone and any summer time zone adjustments (Daylight Savings time in the U.S.A.), according to the TZ string in the user’s environment. Gmtime converts directly to Greenwich Mean Time (GMT), which is the time the HP-UX System uses.
Asctime converts a time value contained in a “tm” structure (as a whole) to a 26-character string, as shown in the above example, and returns a pointer to the string.
Nl_asctime, like nl_ctime, allows the date string to be formatted, and month and weekday names to be in the user’s native language. However, like asctime , it takes “tm” as its argument.
Declarations of all the functions and externals, and the “tm” structure, are in the <time.h> header file. The structure declaration is:
struct tm {
int tm_sec; /∗ seconds (0 - 59) ∗/
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;
long tm_tzadj;
};
Tm_isdst is non-zero if a summer time zone adjustment such as Daylight Savings time is in effect. Tm_tzadj is the difference between GMT and local time expressed in seconds.
The external long variable timezone contains the difference, in seconds, between GMT and local standard time (in EST, timezone is 5∗60∗60); the external variable daylight is non-zero if and only if you have specified a summer time zone adjustment in your TZ environment variable. Daylight and timezone are derived only from the TZ variable value and are independent of any time value. Tm_isdst and tm_tzadj indicate what time zone adjustment is in effect for the value contained in the "tm" structure. The method by which TZ is used for summer time zone adjustment is somewhat complex and is described in tztab(4). The values of the external variables timezone, daylight, and tzname are set from the environment variable TZ by the function tzset, which can be called directly, or indirectly through the functions localtime, ctime, or nl_ctime. TZ is set by default when the user logs on, to a value in the local /etc/profile file, see profile(4).
WARNINGS
The return values point to static data whose content is overwritten by each call.
AUTHOR
Ctime was developed by AT&T and Hewlett-Packard Company.
SEE ALSO
time(2), getenv(3C), langinfo(3C), profile(4), tztab(4), environ(5), hpnls(5).
INTERNATIONAL SUPPORT
8-bit data, messages.
Hewlett-Packard Company — Version B.1, May 11, 2021