safec  3.3
Safe C Library - ISO TR24731 Bounds Checking Interface
gmtime_s.c File Reference
#include "safe_lib.h"
+ Include dependency graph for gmtime_s.c:

Functions

EXPORT struct tm * gmtime_s (const time_t *restrict timer, struct tm *restrict dest)
 The gmtime_s function converts the given time since epoch to a calendar time, expressed in Coordinated Universal Time (UTC) in the struct tm format. More...
 

Function Documentation

◆ gmtime_s()

EXPORT struct tm* gmtime_s ( const time_t *restrict  timer,
struct tm *restrict  dest 
)

The gmtime_s function converts the given time since epoch to a calendar time, expressed in Coordinated Universal Time (UTC) in the struct tm format.

The result is copied into the user-provided tm struct.

Remarks
SPECIFIED IN
  • C11 standard (ISO/IEC 9899:2011): K.3.8.2.3 The gmtime_s function (p: 626-627) http://en.cppreference.com/w/c/chrono/gmtime
  • ISO/IEC TR 24731, Programming languages, environments and system software interfaces, Extensions to the C Library, Part I: Bounds-checking interfaces
Parameters
[in]timerpointer to a epoch (long, seconds since 1970)
[out]destpointer to a user-provided struct tm.
Precondition
timer and dest shall not be a null pointer.
Returns
copy of the dest pointer, or null pointer on error (which may be a runtime constraint violation or a failure to convert the specified time to UTC). May set errno to EOVERFLOW when *timer > 313360441200L, the year 10000, resp. LONG_MAX on 32bit systems or < 0, or to ESNULLP when dest or timer is a NULL pointer.
Note
gmtime returns a pointer to static data and is not thread-safe. When gmtime_r is available it used instead.

POSIX requires that this function sets errno to EOVERFLOW if it fails because the argument is too large. POSIX defines a thread-safe alternative gmtime_r, which is similar to the C11 function gmtime_s, except that it does not check the validity of its input parameters.

This function is available under windows with a different API, reversed argument order, and is not available with safeclib.

See also
localtime_s(), ctime_s()