Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ nl_ascxtime(3C) — HP-UX 9.10

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

time(2)

nl_init(3C)

getdate(3C)

setlocale(3C)

strftime(3C)

tztab(4)

environ(5)

hpnls(5)

lang(5)

langinfo(5)

ctime(3C)

NAME

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

SYNOPSIS

#include <time.h>

char *asctime(const struct tm *timeptr);

char *ctime(const time_t *timer);

double difftime(time_t time1, time_t time0);

struct tm *gmtime(const time_t *timer);

struct tm *localtime(const time_t *timer);

time_t mktime(struct tm *timeptr);

extern long timezone;

extern int daylight;

extern char *tzname[2];

void tzset(void);

char *nl_asctime(const struct tm *timeptr, const char *format, int langid);

char *nl_ascxtime(const struct tm *timeptr, const char *format);

char *nl_ctime(const time_t *timer, const char *format, int langid);

char *nl_cxtime(const time_t *timer, const char *format);

DESCRIPTION

asctime() Convert the broken-down time contained in the structure pointed to by timeptr and return a pointer to a 26-character string in the form:

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

All the fields have constant width. 

ctime() Convert the calendar time pointed to by timer, representing the time in seconds since the Epoch, and return a pointer to the local time in the form of a string. Equivalent to:

asctime(localtime(timer))

gmtime() Convert directly to Coordinated Universal Time (UTC), the time standard used by the HP-UX operating system.  gmtime() returns a pointer to the tm structure described below. 

localtime() Correct for the time zone and any summer time zone adjustments (such as Daylight Savings Time in the USA ), according to the contents of the TZ environment variable (see Environment Variables below).  localtime() returns a pointer to the tm structure described below. 

difftime() Return the difference in seconds between two calendar times: time1 − time0.

mktime() Convert the broken-down time (expressed as local time) in the structure pointed to by timeptr into a calendar time value with the same encoding as that of the values returned by time(2). The original values of the tm_wday and tm_yday components of the structure are ignored, and the original values of the other components are not restricted to the ranges indicated below. 

A positive or zero value for tm_isdst causes mktime() to initially presume that Daylight Saving Time respectively is or is not in effect for the specified time.  A negative value for tm_isdst causes mktime() to attempt to determine whether Daylight Saving Time is in effect for the specified time. 

Upon successful completion, all the components are set to represent the specified calendar time, but with their values forced to the ranges indicated below.  The final value of tm_mday is not set until tm_mon and tm_year are determined.  mktime() returns the specified calendar time encoded as a value of type time_t. 

If the calendar time cannot be represented, the function returns the value (time_t)—1 and sets errno to ERANGE.  Note the value (time_t)—1 also corresponds to the time 23:59:59 on Dec 31, 1969 (plus or minus time zone and Daylight Saving Time adjustments). Thus it is necessary to check both the return value and errno to reliably detect an error condition. 

tzset() Sets the values of the external variables timezone, daylight, and tzname according to the contents of the TZ environment variable (independent of any time value).  The functions localtime(), mktime(), ctime(), nl_ctime(), nl_cxtime(), asctime(), nl_asctime(), nl_ascxtime(), and strftime() (see strftime(3C)) call tzset() and use the values returned in the external variables described below for their operations.  tzset() can also be called directly by the user. 

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_TIME category determines for the functions nl_cxtime(), nl_ctime(), nl_ascxtime(), and nl_asctime() the characters to be substituted for the directives described in strftime(3C) as being from the locale. It also determines the default output format used when a null format string is supplied to these functions.

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 directives and the time zone adjustments performed by localtime(), mktime(), ctime(), nl_ctime(), and nl_cxtime().  Two methods for specifying a time zone within TZ are described in environ(5).

International Code Set Support

Single- and multi-byte character code sets are supported. 

WARNINGS

Return values point to static data whose contents is overwritten by each call. 

The range of tm_sec([0,61]) extends to 61 to allow for the occasional one or two leap seconds.  However, the “seconds since the Epoch” value returned by time(2) and passed as the timer argument does not include accumulated leap seconds.  The tm structure generated by localtime() and gmtime() will never reflect any leap seconds.  Upon successful completion, mktime() forces the value of the tm_sec component to the range [0,59]. 

ctime(), nl_cxtime(), nl_ctime(), asctime(), nl_ascxtime(), and nl_asctime() are considered obsolescent and may be removed in a future release.  Use of strftime(3C) is recommended in their stead.

AUTHOR

ctime() was developed by AT&T and HP. 

SEE ALSO

time(2), nl_init(3C), getdate(3C), setlocale(3C), strftime(3C), tztab(4), environ(5), hpnls(5), lang(5), langinfo(5). 

STANDARDS CONFORMANCE

ctime(): AES, SVID2, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C
asctime(): AES, SVID2, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

daylight: AES, SVID2, XPG2, XPG3, XPG4
difftime(): AES, XPG4, ANSI C

gmtime(): AES, SVID2, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C
localtime(): AES, SVID2, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

mktime(): AES, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C
nl_ascxtime(): XPG2

nl_cxtime(): XPG2
timezone: AES, XPG2, XPG3, XPG4

tzname: AES, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1
tzset(): AES, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1

Hewlett-Packard Company  —  HP-UX Release 9.10: April 1995

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