Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ctime(3) — AIX/RT 2.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

time

getenv, NLgetenv

NLstrtime

NLtmtime

profile

environment

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 tm  structure is defined  in the time.h  header file,
     and it contains 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; /* 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, then 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 to the value  that is
     defined  in  either   /etc/environment  or  /etc/profile.
     However, 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 S 60 S 60  for   U.S.  Eastern
     Standard Time.

     The daylight  external variable  is non-zero when  a day-
     light  saving  time  conversion should  be  applied.   By
     default, this  conversion follows the standard  U.S. con-
     ventions;  other  conventions   can  be  specified.   The
     default  conversion algorithm  adjusts for  the peculiar-
     ities 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."

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