"Fossies" - the Fresh Open Source Software Archive

Member "newctime.3.txt" (16 Jul 2018, 8266 Bytes) of package /linux/misc/tzcode2018i.tar.gz:

As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "newctime.3.txt": 2018e_vs_2018f.

    1 NEWCTIME(3)                Library Functions Manual                NEWCTIME(3)
    3 NAME
    4        asctime, ctime, difftime, gmtime, localtime, mktime - convert date and
    5        time
    8        #include <time.h>
   10        extern char *tzname[]; /* (optional) */
   12        char *ctime(time_t const *clock);
   14        char *ctime_r(time_t const *clock, char *buf);
   16        double difftime(time_t time1, time_t time0);
   18        char *asctime(struct tm const *tm);
   20        char *asctime_r(struct tm const *restrict tm,
   21            char *restrict result);
   23        struct tm *localtime(time_t const *clock);
   25        struct tm *localtime_r(time_t const *restrict clock,
   26            struct tm *restrict result);
   28        struct tm *localtime_rz(timezone_t restrict zone,
   29            time_t const *restrict clock,
   30            struct tm *restrict result);
   32        struct tm *gmtime(time_t const *clock);
   34        struct tm *gmtime_r(time_t const *restrict clock,
   35            struct tm *restrict result);
   37        time_t mktime(struct tm *tm);
   39        time_t mktime_z(timezone_t restrict zone,
   40            struct tm *restrict tm);
   42        cc ... -ltz
   45        Ctime converts a long integer, pointed to by clock, and returns a
   46        pointer to a string of the form
   47                             Thu Nov 24 18:22:48 1986\n\0
   48        Years requiring fewer than four characters are padded with leading
   49        zeroes.  For years longer than four characters, the string is of the
   50        form
   51                           Thu Nov 24 18:22:48     81986\n\0
   52        with five spaces before the year.  These unusual formats are designed
   53        to make it less likely that older software that expects exactly 26
   54        bytes of output will mistakenly output misleading values for out-of-
   55        range years.
   57        The *clock timestamp represents the time in seconds since 1970-01-01
   58        00:00:00 Coordinated Universal Time (UTC).  The POSIX standard says
   59        that timestamps must be nonnegative and must ignore leap seconds.  Many
   60        implementations extend POSIX by allowing negative timestamps, and can
   61        therefore represent timestamps that predate the introduction of UTC and
   62        are some other flavor of Universal Time (UT).  Some implementations
   63        support leap seconds, in contradiction to POSIX.
   65        Localtime and gmtime return pointers to "tm" structures, described
   66        below.  Localtime corrects for the time zone and any time zone
   67        adjustments (such as Daylight Saving Time in the United States).  After
   68        filling in the "tm" structure, localtime sets the tm_isdst'th element
   69        of tzname to a pointer to a string that's the time zone abbreviation to
   70        be used with localtime's return value.
   72        Gmtime converts to Coordinated Universal Time.
   74        Asctime converts a time value contained in a "tm" structure to a
   75        string, as shown in the above example, and returns a pointer to the
   76        string.
   78        Mktime converts the broken-down time, expressed as local time, in the
   79        structure pointed to by tm into a calendar time value with the same
   80        encoding as that of the values returned by the time function.  The
   81        original values of the tm_wday and tm_yday components of the structure
   82        are ignored, and the original values of the other components are not
   83        restricted to their normal ranges.  (A positive or zero value for
   84        tm_isdst causes mktime to presume initially that daylight saving time
   85        respectively, is or is not in effect for the specified time.  A
   86        negative value for tm_isdst causes the mktime function to attempt to
   87        divine whether daylight saving time is in effect for the specified
   88        time; in this case it does not use a consistent rule and may give a
   89        different answer when later presented with the same argument.)  On
   90        successful completion, the values of the tm_wday and tm_yday components
   91        of the structure are set appropriately, and the other components are
   92        set to represent the specified calendar time, but with their values
   93        forced to their normal ranges; the final value of tm_mday is not set
   94        until tm_mon and tm_year are determined.  Mktime returns the specified
   95        calendar time; If the calendar time cannot be represented, it returns
   96        -1.
   98        Difftime returns the difference between two calendar times, (time1 -
   99        time0), expressed in seconds.
  101        Ctime_r, localtime_r, gmtime_r, and asctime_r are like their unsuffixed
  102        counterparts, except that they accept an additional argument specifying
  103        where to store the result if successful.
  105        Localtime_rz and mktime_z are like their unsuffixed counterparts,
  106        except that they accept an extra initial zone argument specifying the
  107        timezone to be used for conversion.  If zone is null, UT is used;
  108        otherwise, zone should be have been allocated by tzalloc and should not
  109        be freed until after all uses (e.g., by calls to strftime) of the
  110        filled-in tm_zone fields.
  112        Declarations of all the functions and externals, and the "tm"
  113        structure, are in the <time.h> header file.  The structure (of type)
  114        struct tm includes the following fields:
  116                 int tm_sec;      /* seconds (0-60) */
  117                 int tm_min;      /* minutes (0-59) */
  118                 int tm_hour;     /* hours (0-23) */
  119                 int tm_mday;     /* day of month (1-31) */
  120                 int tm_mon;      /* month of year (0-11) */
  121                 int tm_year;     /* year - 1900 */
  122                 int tm_wday;     /* day of week (Sunday = 0) */
  123                 int tm_yday;     /* day of year (0-365) */
  124                 int tm_isdst;    /* is daylight saving time in effect? */
  125                 char *tm_zone;   /* time zone abbreviation (optional) */
  126                 long tm_gmtoff;  /* offset from UT in seconds (optional) */
  128        Tm_isdst is non-zero if daylight saving time is in effect.
  130        Tm_gmtoff is the offset (in seconds) of the time represented from UT,
  131        with positive values indicating east of the Prime Meridian.  The
  132        field's name is derived from Greenwich Mean Time, a precursor of UT.
  134        In struct tm the tm_zone and tm_gmtoff fields exist, and are filled in,
  135        only if arrangements to do so were made when the library containing
  136        these functions was created.  Similarly, the tzname variable is
  137        optional.  There is no guarantee that these fields and this variable
  138        will continue to exist in this form in future releases of this code.
  140 FILES
  141        /usr/share/zoneinfo             timezone information directory
  142        /usr/share/zoneinfo/localtime   local timezone file
  143        /usr/share/zoneinfo/posixrules  used with POSIX-style TZ's
  144        /usr/share/zoneinfo/GMT         for UTC leap seconds
  146        If /usr/share/zoneinfo/GMT is absent, UTC leap seconds are loaded from
  147        /usr/share/zoneinfo/posixrules.
  149 SEE ALSO
  150        getenv(3), newstrftime(3), newtzset(3), time(2), tzfile(5)
  152 NOTES
  153        The return values of asctime, ctime, gmtime, and localtime point to
  154        static data overwritten by each call.  The tzname variable (once set)
  155        and the tm_zone field of a returned struct tm both point to an array of
  156        characters that can be freed or overwritten by later calls to the
  157        functions localtime, tzfree, and tzset, if these functions affect the
  158        timezone information that specifies the abbreviation in question.  The
  159        remaining functions and data are thread-safe.
  161        Asctime, asctime_r, ctime, and ctime_r behave strangely for years
  162        before 1000 or after 9999.  The 1989 and 1999 editions of the C
  163        Standard say that years from -99 through 999 are converted without
  164        extra spaces, but this conflicts with longstanding tradition and with
  165        this implementation.  The 2011 edition says that the behavior is
  166        undefined if the year is before 1000 or after 9999.  Traditional
  167        implementations of these two functions are restricted to years in the
  168        range 1900 through 2099.  To avoid this portability mess, new programs
  169        should use strftime instead.
  171                                                                    NEWCTIME(3)