Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ctime(3C) — HP-UX 6.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

time(2)

getenv(3C)

langinfo(3C)

nl_init(3C)

profile(4)

printf(3S)

tztab(4)

environ(5)

hpnls(5)

langid(5)

CTIME(3C)  —  HP-UX

NAME

ctime, nl_cxtime, localtime, gmtime, asctime, nl_ascxtime, timezone, daylight, tzname, tzset, nl_ctime, nl_asctime − convert date and time to string

SYNOPSIS

#include <time.h>

char ∗ctime (clock)
long ∗clock;

char ∗nl_cxtime (clock, format)
long ∗clock;
char ∗format;

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_ascxtime (tm, format)
struct tm ∗tm;
char ∗format;

char ∗nl_asctime (tm, format, langid)
struct tm ∗tm;
char ∗format;
int langid;

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:

Sun Sep 16 01:03:52 1973\n\0

All the fields have constant width. 

Nl_cxtime extends the capabilities of ctime. 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. Month and weekday names in the output string will be in the language of the currently loaded NLS environment (see nl_init(3C)). If nl_init has not been called successfully, the month and weekday names of the default NLS environment, ­"n-computer" (see langid(5)), are used.

Nl_ctime performs in a manner similar to nl_cxtime, but effectively first calls langinit (see nl_init(3C)) to load the NLS environment according to the language specified by langid.  Nl_ctime also appends a newline to the formatted string.  Nl_ctime is provided for historical reasons only; its use is not recommended. 

Localtime and gmtime return pointers to tm structures, described below.  Localtime corrects for the time zone and any summer time zone adjustments (such as Daylight Savings Time in the USA), 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 an entire tm structure to a 26-character string, as shown in the above example, and returns a pointer to the string. 

Nl_ascxtime, like nl_cxtime, allows the date string to be formatted, and month and weekday names to appear in the language of the NLS environment loaded.  However, like asctime, nl_asctime takes tm as its argument. 

Nl_asctime performs like nl_ascxtime, but first calls langinit (see nl_init(3C)) to load the NLS environment according to the language specified by langid.  Nl_asctime also appends a newline to the formatted string.  Nl_asctime is provided for historical reasons only; its use is not recommended. 

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 (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; /∗ daylight savings time flag ∗/

Tm_isdst is non-zero if a summer time zone adjustment such as Daylight Savings Time is in effect. 

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 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.  The method by which TZ is used for summer time zone adjustment is 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 to a value in the local /etc/profile file (see profile(4)) when the user logs on.

WARNINGS

The return values point to static data whose content is overwritten by each call. 

DEPENDENCIES

Series 500
Nl_cxtime and nl_ascxtime are not currently supported; use nl_ctime and nl_asctime instead. 

AUTHOR

Ctime was developed by AT&T and HP. 

SEE ALSO

time(2), getenv(3C), langinfo(3C), nl_init(3C), profile(4), printf(3S), tztab(4), environ(5), hpnls(5), langid(5). 

INTERNATIONAL SUPPORT

8- and 16-bit data, messages. 

Hewlett-Packard Company  —  Version B.1,  May 11, 2021

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026