2 * COPYRIGHT: LGPL, See LGPL.txt in the top level directory
3 * PROJECT: ReactOS CRT library
4 * FILE: lib/sdk/crt/time/ctime.c
5 * PURPOSE: Implementation of ctime, _ctime_s
6 * PROGRAMERS: Timo Kreuzer
8 #define MINGW_HAS_SECURE_API 1
10 #define RC_INVOKED 1 // to prevent inline functions
13 #include "bitsfixup.h"
17 /* Doesn't really exist, but we need it here */
18 _CRTIMP errno_t __cdecl
localtime_s(struct tm
*_Tm
,const time_t *_Time
);
20 /******************************************************************************
22 * \brief Converts a time_t value into a string.
23 * \param buffer Buffer that receives the string (26 characters).
24 * \param numberOfElements Size of the buffer in characters.
25 * \param time Pointer to the UTC time.
28 _tctime_s(_TCHAR
*buffer
, size_t numberOfElements
, const time_t *time
)
32 if (localtime_s(&_tm
, time
) == EINVAL
)
36 return _tasctime_s(buffer
, numberOfElements
, &_tm
);
39 /******************************************************************************
41 * \brief Converts a time_t value into a string and returns a pointer to it.
42 * \param time Pointer to the UTC time.
43 * \remarks The string is stored in thread local buffer, shared between
44 * ctime, gmtime and localtime (both 32 and 64 bit versions).
47 _tctime(const time_t *ptime
)
49 struct tm
*ptm
= localtime(ptime
);
54 return _tasctime(ptm
);