HELPLIB.HLB  —  CRTL  asctime
    Converts a broken-down time in a tm structure into a 26-character
    string in the following form:

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

    All fields have a constant width.

    Format

      #include  <time.h>

      char *asctime  (const struct tm *timeptr);

      char *asctime_r  (const struct tm *timeptr, char *buffer);

                                                  (ISO POSIX-1)

1  –  Arguments

 timeptr

    A pointer to a structure of type tm, which contains the broken-
    down time.

    The tm structure is defined in the <time.h> header file, and also
    shown in tm Structure in the description of localtime.

 buffer

    A pointer to a character array that is at least 26 bytes long.
    This array is used to store the generated date-and-time string.

2  –  Description

    The asctime and asctime_r functions convert the contents of tm
    into a 26-character string and returns a pointer to the string.

    The difference between asctime_r and asctime is that the former
    puts the result into a user-specified buffer. The latter puts
    the result into thread-specific static memory allocated by the
    C RTL, which can be overwritten by subsequent calls to
    ctime or asctime; you must make a copy if you want to save it.

    On success, asctime returns a pointer to the string; asctime_r
    returns its second argument. On failure, these functions return
    the NULL pointer.

    See the localtime function for a list of the members in tm.

                                   NOTE

       Generally speaking, UTC-based time functions can affect in-
       memory time-zone information, which is processwide data.
       However, if the system time zone remains the same during
       the execution of the application (which is the common case)
       and the cache of timezone files is enabled (which is the
       default), then the _r variant of the time functions asctime_
       r, ctime_r, gmtime_r and localtime_r, is both thread-safe
       and AST-reentrant.

       If, however, the system time zone can change during the
       execution of the application or the cache of timezone files
       is not enabled, then both variants of the UTC-based time
       functions belong to the third class of functions, which are
       neither thread-safe nor AST-reentrant.

3  –  Return Values

    x                  A pointer to the string, if successful.
    NULL               Indicates failure.
Close Help