Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ctime(3) — GDT-UNX 6.8_er0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

time(2)

CTIME(3)  —  UNIX Programmer’s Manual

NAME

ctime, localtime, gmtime, asctime, timezone −  convert date and time to ASCII

SYNOPSIS

char \(**ctime(clock)
long \(**clock;

#include <time.h>

struct tm \(**localtime(clock)
long \(**clock;

struct tm \(**gmtime(clock)
long \(**clock;

char \(**asctime(tm)
struct tm \(**tm;

char \(**timezone(zone, dst)

DESCRIPTION

Ctime converts a time pointed to by clock such as returned by time(2) into ASCII 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

Localtime and gmtime return pointers to structures containing the broken-down time.  Localtime corrects for the time zone and possible daylight savings time; gmtime converts directly to GMT, which is the time UNIX uses.  Asctime converts a broken-down time to ASCII and returns a pointer to a 26-character string. 

The structure declaration from the include file is:

/\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**
                           Copyright  1982
                VALID  LOGIC  SYSTEMS  INCORPORATED
 This listing contains confidential proprietary information which is not to
be disclosed to unauthorized persons without written consent of an officer
of Valid Logic Systems Incorporated.
 The copyright notice appearing above is included to provide statutory
protection in the event of unauthorized or unintentional public disclosure.
 \(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**\(**/
 struct tm { /\(** see ctime(3) \(**/
inttm_sec;
inttm_min;
inttm_hour;
inttm_mday;
inttm_mon;
inttm_year;
inttm_wday;
inttm_yday;
inttm_isdst;
};

These quantities give the time on a 24-hour clock, day of month (1-31), month of year (0-11), day of week (Sunday = 0), year − 1900, day of year (0-365), and a flag that is nonzero if daylight saving time is in effect. 

When local time is called for, the program consults the system to determine the time zone and whether the standard U.S.A. daylight saving time adjustment is appropriate.  The program knows about the peculiarities of this conversion in 1974 and 1975; if necessary, a table for these years can be extended. 

Timezone returns the name of the time zone associated with its first argument, which is measured in minutes westward from Greenwich.  If the second argument is 0, the standard name is used, otherwise the Daylight Saving version.  If the required name does not appear in a table built into the routine, the difference from GMT is produced; e.g.  in Afghanistan timezone(-(60\(**4+30), 0) is appropriate because it is 4:30 ahead of GMT and the string GMT+4:30 is produced. 

SEE ALSO

time(2)

BUGS

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

August 03, 1983  —  %W%%Q%%Y%

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