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

Functions

EXPORT struct tm * localtime_s (const time_t *restrict timer, struct tm *restrict dest)
 The localtime_s function converts the given time since epoch to a calendar time, expressed in the current timezone in the struct tm format. More...
 

Function Documentation

◆ localtime_s()

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

The localtime_s function converts the given time since epoch to a calendar time, expressed in the current timezone 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.4 The localtime_s function (p: 627) http://en.cppreference.com/w/c/chrono/localtime
  • 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 the current timezone). 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
localtime returns a pointer to static data and is not thread-safe. When localtime_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 localtime_r, which is similar to the C11 function localtime_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
gmtime_s(), ctime_s()