VMS Help  —  CRTL  gmtime
    Converts time units to the broken-down UTC time.

    Format

      #include  <time.h>

      struct tm *gmtime  (const time_t *timer);

      struct tm *gmtime_r  (const time_t *timer, struct tm *result);
                           (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
    the gmtime_r function that is equivalent to the behavior before
    OpenVMS Version 7.0.

2  –  Arguments

 timer

    Points to a variable that specifies a time value in seconds since
    the Epoch.

 result

    A pointer to a tm structure where the result is stored.

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

3  –  Description

    The gmtime and gmtime_r functions convert the time (in seconds
    since the Epoch) pointed to by timer into a broken-down time,
    expressed as Coordinated Universal Time (UTC), and store it in a
    tm structure.

    The difference between the gmtime_r and gmtime functions is that
    the former puts the result into a user-specified tm structure
    where the result is stored. The latter puts the result into
    thread-specific static memory allocated by the C RTL,
    and which is overwritten by subsequent calls to gmtime; you must
    make a copy if you want to save it.

    On success, gmtime returns a pointer to the tm structure; gmtime_
    r returns its second argument. On failure, these functions return
    the NULL pointer.

                                   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                  Pointer to a tm structure.
    NULL               Indicates an error; errno is set to the
                       following value:

                       o  EINVAL - The timer argument is NULL.
Close Help