man(1) Manual page archive


     CTIME(3)                                                 CTIME(3)

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

     SYNOPSIS
          #include <time.h>

          char *ctime(clock)
          long *clock;

          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 contain-
          ing 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 con-
          verts a broken-down time to ASCII and returns a pointer to a
          26-character string.

          struct tm {
                  int tm_sec;     seconds (range 0..59)
                  int tm_min;     minutes (0..59)
                  int tm_hour;    hours (0..23)
                  int tm_mday;    day of the month (1..31)
                  int tm_mon;     month of the year (0..11)
                  int tm_year;    year A.D. - 1900
                  int tm_wday;    day of week (0..6, Sunday = 0)
                  int tm_yday;    day of year (0..365)
                  int tm_isdst;   zero means normal time, nonzero means daylight saving time
          };

          When local time is called for, the program consults the sys-
          tem to determine the time zone and whether the standard

     CTIME(3)                                                 CTIME(3)

          U.S.A. daylight saving time adjustment is appropriate.  The
          peculiarities of this conversion are read from the file
          which contains lines of the form

               y0 y1 bmon bday boff emon eday eoff

          meaning that for years between y0 and y1 inclusive, daylight
          saving time begins (ends) boff (eoff) days after the first
          Sunday after the day bmon/bday (emon/eday).

          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 rou-
          tine, the difference from GMT is produced.  Thus, as Afghan-
          istan is 4:30 ahead of GMT, timezone(-(60*4+30), 0) returns
          "GMT+4:30".

     SEE ALSO
          time(2), timec(3)

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