ReactOS 0.4.16-dev-109-gf4cb10f
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 */
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
#define EINVAL
Definition: acclib.h:90
#define __cdecl
Definition: accygwin.h:79
#define _CRTIMP
Definition: crtdefs.h:72
int errno_t
Definition: crtdefs.h:374
_CRTIMP errno_t __cdecl localtime_s(struct tm *_Tm, const time_t *_Time)
Definition: time.h:417
__kernel_time_t time_t
Definition: linux.h:252
GLuint buffer
Definition: glext.h:5915
#define _tctime_s
Definition: tchar.h:666
char _TCHAR
Definition: tchar.h:1392
#define _tasctime
Definition: tchar.h:653
#define _tasctime_s
Definition: tchar.h:665
#define _tctime
Definition: tchar.h:654
__u16 time
Definition: mkdosfs.c:8
static size_t numberOfElements
Definition: string.c:87
_In_ size_t _In_z_ _Printf_format_string_ const char _In_ const struct tm * _Tm
Definition: time.h:148
_In_ size_t _In_ const __time32_t * _Time
Definition: time.h:192
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
Definition: time.h:416
Definition: time.h:68