Namespaces
Variants
Actions

localtime, localtime_r, localtime_s

From cppreference.com
< c‎ | chrono
Defined in header <time.h>
struct tm* localtime  ( const time_t* timer );
(1)
struct tm* localtime_r( const time_t* timer, struct tm* buf );
(2) (since C23)
struct tm* localtime_s( const time_t* restrict timer, struct tm* restrict buf );
(3) (since C11)
1) Converts given time since epoch (a time_t value pointed to by timer) into calendar time, expressed in local time, in the struct tm format. The result is stored in static storage and a pointer to that static storage is returned.
2) Same as (1), except that the function uses user-provided storage buf for the result.
3) Same as (1), except that the function uses user-provided storage buf for the result and that the following errors are detected at runtime and call the currently installed constraint handler function:
  • timer or buf is a null pointer
As with all bounds-checked functions, localtime_s is only guaranteed to be available if __STDC_LIB_EXT1__ is defined by the implementation and if the user defines __STDC_WANT_LIB_EXT1__ to the integer constant 1 before including <time.h>.

Contents

[edit] Parameters

timer - pointer to a