Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ctime(3) — AIX PS/2 1.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

time

getenv, NLgetenv

NLstrtime

NLtmtime

profile

environment



CTIME(3,L)                  AIX Technical Reference                  CTIME(3,L)



-------------------------------------------------------------------------------
ctime, localtime, gmtime, asctime, tzset



PURPOSE

Converts date and time to string representation.

LIBRARY

Standard C Library (libc.a)

SYNTAX

#include <time.h>



      char *ctime (clock)                 char *asctime (tm)
      long *clock;                        struct tm *tm;

      struct tm *localtime (clock)        void tzset ( )
      long *clock;
                                          extern long timezone;
      struct tm *gmtime (clock)           extern int daylight;
      long *clock;                        extern char *tzname[2];



DESCRIPTION

The ctime subroutine converts a time value pointed to by the clock parameter,
which represents the time in seconds since 00:00:00 Greenwich Mean Time (GMT),
January 1, 1970, into a 26-character string in the following form:

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

The width of each field is always the same as shown here.

The localtime subroutine converts the long integer pointed to by the clock
parameter, which contains the time in seconds since 00:00:00 GMT, January 1,
1970, into a tm structure.  localtime adjusts for the time zone and for
daylight saving time, if it is in effect.

The gmtime subroutine converts the long integer pointed to by the clock
parameter into a tm structure containing the Greenwich Mean Time, which is the
time that AIX uses.  The gmtime routine always sets tm_isdst to FALSE;
localtime must be used to inquire about daylight savings time.

The tm structure is defined in the time.h header file, and it contains the
following members:



Processed November 7, 1990        CTIME(3,L)                                  1





CTIME(3,L)                  AIX Technical Reference                  CTIME(3,L)




      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; /* Nonzero = Daylight saving time */

The asctime subroutine converts a tm structure to a 26-character string of the
same format as ctime.

If the TZ environment variable is defined, its value overrides the default time
zone, which is the U.S. Eastern time zone.  See "environment" for the format of
the time zone information specified by TZ.  TZ is usually set when the system
is started up.  Its value is defined in either /etc/environment or
/etc/profile.  It can also be set by the user as a regular environment variable
for performing alternate time zone conversions.

The tzset subroutine sets the timezone, daylight, and tzname external variables
to reflect the setting of TZ.  tzset is called by ctime and localtime, and it
can also be called explicitly by an application program.

The timezone external variable contains the difference, in seconds, between GMT
and local standard time.  For example, timezone is 5 * 60 * 60 for U.S. Eastern
Standard Time.

The daylight external variable is nonzero if an alternate timezone is defined
in the TZ environment variable.  By default, this conversion follows the
standard U.S. conventions; other conventions can be specified.  The default
conversion algorithm adjusts for the peculiarities of U.S. daylight saving time
in 1974 and 1975.  See "environment" for information about specifying alternate
daylight saving time conventions.

The tzname external variable contains the name of the standard time zone
(tzname[0]) and of the time zone when daylight saving time is in effect
(tzname[1]).  For example:

      char *tzname[2] = {"EST", "EDT"};

The time.h header file contains declarations of all these subroutines,
externals, and the tm structure.

Warning:  The return values point to static data that is overwritten by each
call.

RELATED INFORMATION

In this book:  "time,"  "getenv, NLgetenv," "NLstrtime,"  "NLtmtime,"
"profile," and  "environment."



Processed November 7, 1990        CTIME(3,L)                                  2



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