VMS Help  —  CRTL  ctime
    Converts a time in seconds, since 00:00:00 January 1, 1970, to an
    ASCII string in the form generated by the asctime function.

    Format

      #include  <time.h>

      char *ctime  (const time_t *bintim);

      char *ctime_r  (const time_t *bintim, char *buffer);
                           (ISO POSIX-1)

1  –  Function Variants

    Compiling with the _DECC_V4_SOURCE and _VMS_V6_SOURCE feature-
    test macros defined enables a local-time-based entry point to
    this function that is equivalent to the behavior before OpenVMS
    Version 7.0.

2  –  Arguments

 bintim

    A pointer to a variable that specifies the time value (in
    seconds) to be converted.

 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.

3  –  Description

    The ctime and ctime_r functions convert the time pointed to by
    bintim into a 26-character string, and return a pointer to the
    string.

    The difference between the ctime_r and ctime functions is that
    the former puts its result into a user-specified buffer. The
    latter puts its result into thread-specific static memory
    allocated by the Compaq 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, ctime returns a pointer to the string; ctime_r
    returns its second argument. On failure, these functions return
    the NULL pointer.

    The type time_t is defined in the <time.h> header file as
    follows:

    typedef long int time_t

    The ctime function behaves as if it called tzset.

                                   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.

4  –  Return Values

    x                  A pointer to the 26-character ASCII string, if
                       successful.
    NULL               Indicates failure.
Close Help