ReactOS  0.4.15-dev-1632-g4e289ce
ctime.c
Go to the documentation of this file.
1 /*
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
7  */
8 #define MINGW_HAS_SECURE_API 1
9 
10 #include <errno.h>
11 #define RC_INVOKED 1 // to prevent inline functions
12 #include <tchar.h>
13 #include <time.h>
14 #include "bitsfixup.h"
15 
16 /* Doesn't really exist, but we need it here */
18 
19 /******************************************************************************
20  * \name _tctime_s
21  * \brief Converts a time_t value into a string.
22  * \param buffer Buffer that receives the string (26 characters).
23  * \param numberOfElements Size of the buffer in characters.
24  * \param time Pointer to the UTC time.
25  */
26 errno_t
28 {
29  struct tm _tm;
30 
31  if (localtime_s(&_tm, time) == EINVAL)
32  {
33  return EINVAL;
34  }
35  return _tasctime_s(buffer, numberOfElements, &_tm);
36 }
37 
38 /******************************************************************************
39  * \name _tctime
40  * \brief Converts a time_t value into a string and returns a pointer to it.
41  * \param time Pointer to the UTC time.
42  * \remarks The string is stored in thread local buffer, shared between
43  * ctime, gmtime and localtime (both 32 and 64 bit versions).
44  */
45 _TCHAR *
46 _tctime(const time_t *ptime)
47 {
48  struct tm *ptm = localtime(ptime);
49  if (!ptm)
50  {
51  return 0;
52  }
53  return _tasctime(ptm);
54 }
55 
_TCHAR * _tctime(const time_t *ptime)
Definition: ctime.c:46
#define __cdecl
Definition: accygwin.h:79
#define _CRTIMP
Definition: crtdefs.h:60
Definition: arc.h:39
GLuint buffer
Definition: glext.h:5915
_TCHAR * _tasctime(const struct tm *ptm)
Definition: asctime.c:150
__u16 time
Definition: mkdosfs.c:366
static size_t numberOfElements
Definition: string.c:87
int errno_t
Definition: crtdefs.h:353
char _TCHAR
Definition: tchar.h:1392
errno_t _tctime_s(_TCHAR *buffer, size_t numberOfElements, const time_t *time)
Definition: ctime.c:27
_In_ size_t _In_z_ _Printf_format_string_ const char _In_ const struct tm * _Tm
Definition: time.h:156
errno_t _tasctime_s(_TCHAR *buffer, size_t numberOfElements, const struct tm *ptm)
Definition: asctime.c:106
Definition: time.h:76
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
Definition: time.h:424
__kernel_time_t time_t
Definition: linux.h:252
_CRTIMP errno_t __cdecl localtime_s(struct tm *_Tm, const time_t *_Time)
Definition: time.h:425
_In_ size_t _In_ const __time32_t * _Time
Definition: time.h:199