Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ctime(3C) — HP-UX 5.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

time(2)

getenv(3C)

langinfo(3C)

profile(5)

environ(7)

hpnls(7)

CTIME(3C)

NAME

ctime, nl_ctime, daylight, localtime, gmtime, asctime, nl_asctime, timezone, tzset, tzname − 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 ( )

HP-UX COMPATIBILITY

Level: HP-UX/RUN ONLY

Origin: System V

Native Language Support:
8−bit data, customs, messages

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 corrections (Daylight Savings time in the US), 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 “tm” structure 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;
};

Tm_isdst is non-zero if a summer time zone correction 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 if and only if you have specified a summer time zone correction in your TZ environment variable.  The values of the external variables timezone, daylight, and tzname are set from the environment variable TZ by the function tzset, which may 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(5)).

HARDWARE DEPENDENCIES

Series 200/500:
Tztab(5) is not currently supported.

SEE ALSO

time(2), getenv(3C), langinfo(3C), profile(5), environ(7), hpnls(7). 

BUGS

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

Hewlett-Packard  —  last mod. May 11, 2021

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