gmtime_r(), gmtime64_r() — Convert a time value to broken-down UTC time

Standards

Standards / Extensions C or C++ Dependencies

Single UNIX Specification, Version 2
Single UNIX Specification, Version 3
Language Environment®

both OS/390 V2R8

Format

#define _XOPEN_SOURCE 500
#include <time.h>

struct tm *gmtime_r(const time_t *__restrict__ clock, 
                    struct tm *__restrict__ result);
#define _LARGE_TIME_API
#include <time.h>

struct tm *gmtime64 _r(const time64_t *__restrict__ clock, 
                     struct tm *__restrict__ result); 

General description

The gmtime_r() function converts the calendar time pointed to by clock into a broken-down time expressed as Coordinated Universal Time (UTC). The broken-down time is stored in the structure referred to by result. The gmtime_r() function also returns the address of the same structure.

The relationship between a time in seconds since the Epoch used as an argument to gmtime() and the tm structure (defined in the <time.h> header) is that the result is as specified in the expression given in the definition of seconds since the Epoch, where the names in the structure and in the expression correspond.

The function gmtime64_r() will behave exactly like gmtime_r() except it will break down a time64_t value pointing to a calendar time beyond 03:14:07 UTC on January 19, 2038 with a limit of 23:59:59 UTC on December 31, 9999.

Returned value

If successful, gmtime_r() returns the address of the structure pointed to by the argument result.

If an error is detected or UTC is not available, gmtime_r() returns a NULL pointer.

There are no documented errno values.

Error Code
Description
EOVERFLOW
The result cannot be represented.

Related information