1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#include "localtime_r.h"
#if __cplusplus <= CPLUSPLUS_20
#include <time.h>
#include <errno.h>
#include "../global.h"
#if defined (WINDOWS)
struct tm* localtime_r(const time_t* timer, struct tm* buf) {
/* NOTE: careful here!
*
* MSDN : errno_t localtime_s(struct tm* const tmDest, time_t const* const sourceTime);
* C++11: struct tm* localtime_s(const time_t* restrict timer, struct tm* restrict buf);
*/
// cppcheck-suppress AssignmentAddressToInteger
errno_t r = localtime_s(buf, timer);
if (r != 0)
errno = EINVAL;
else
errno = 0;
return buf;
}
#endif
#endif
|