ReactOS  0.4.15-dev-506-ga3ec01c
asctime.c File Reference
#include <precomp.h>
#include <tchar.h>
#include <time.h>
#include "bitsfixup.h"
Include dependency graph for asctime.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  timebuf_t
 

Macros

#define DAYSPERWEEK   7
 
#define MONSPERYEAR   12
 
#define HUNDREDYEAROFFSET   19
 

Typedefs

typedef unsigned long _TCHAR4
 
typedef unsigned short _TCHAR2
 

Functions

FORCEINLINE _TCHAR2 IntToChar2 (int x)
 
static __inline void FillBuf (timebuf_t *buf, const struct tm *ptm)
 
errno_t _tasctime_s (_TCHAR *buffer, size_t numberOfElements, const struct tm *ptm)
 
_TCHAR_tasctime (const struct tm *ptm)
 

Variables

static const _TCHAR wday_name [DAYSPERWEEK][5]
 
static const _TCHAR mon_name [MONSPERYEAR][5]
 

Macro Definition Documentation

◆ DAYSPERWEEK

#define DAYSPERWEEK   7

Definition at line 13 of file asctime.c.

◆ HUNDREDYEAROFFSET

#define HUNDREDYEAROFFSET   19

Definition at line 15 of file asctime.c.

◆ MONSPERYEAR

#define MONSPERYEAR   12

Definition at line 14 of file asctime.c.

Typedef Documentation

◆ _TCHAR2

Definition at line 34 of file asctime.c.

◆ _TCHAR4

Definition at line 33 of file asctime.c.

Function Documentation

◆ _tasctime()

_TCHAR* _tasctime ( const struct tm ptm)

Definition at line 150 of file asctime.c.

151 {
153  _TCHAR *pstr;
154 
155 #ifndef _UNICODE
156  pstr = data->asctime_buffer;
157 #else
158  pstr = data->wasctime_buffer;
159 #endif
160 
161  if(!pstr)
162  pstr = malloc(sizeof(struct tm));
163 
164  /* Fill the buffer */
165  FillBuf((timebuf_t*)pstr, ptm);
166 
167  return pstr;
168 }
static __inline void FillBuf(timebuf_t *buf, const struct tm *ptm)
Definition: asctime.c:78
char _TCHAR
Definition: tchar.h:1392
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
Definition: time.h:76
thread_data_t * msvcrt_get_thread_data(void)
Definition: tls.c:31
#define malloc
Definition: debug_ros.c:4

Referenced by _tctime(), and ShowInfo().

◆ _tasctime_s()

errno_t _tasctime_s ( _TCHAR buffer,
size_t  numberOfElements,
const struct tm ptm 
)

Definition at line 106 of file asctime.c.

110 {
111  /* Validate parameters */
112  if (!buffer || numberOfElements < 26 || !ptm ||
113  (unsigned int)ptm->tm_sec > 59 ||
114  (unsigned int)ptm->tm_min > 59 ||
115  (unsigned int)ptm->tm_hour > 23 ||
116  (unsigned int)ptm->tm_mday > 31 ||
117  (unsigned int)ptm->tm_mon > 11 ||
118  (unsigned int)ptm->tm_year > 2038 ||
119  (unsigned int)ptm->tm_wday > 6 ||
120  (unsigned int)ptm->tm_yday > 365)
121  {
122 #if 0
124 #ifdef UNICODE
125  L"_wasctime",
126 #else
127  L"asctime",
128 #endif
129  _CRT_WIDE(__FILE__),
130  __LINE__,
131  0);
132 #endif
133  return EINVAL;
134  }
135 
136  /* Fill the buffer */
137  FillBuf((timebuf_t*)buffer, ptm);
138 
139  return 0;
140 }
wchar_t UNICODE
Definition: ms-dtyp.idl:111
int tm_min
Definition: time.h:78
static __inline void FillBuf(timebuf_t *buf, const struct tm *ptm)
Definition: asctime.c:78
Definition: arc.h:39
int tm_mday
Definition: time.h:80
GLuint buffer
Definition: glext.h:5915
int tm_year
Definition: time.h:82
static size_t numberOfElements
Definition: string.c:87
smooth NULL
Definition: ftsmooth.c:416
int tm_mon
Definition: time.h:81
static const WCHAR L[]
Definition: oid.c:1250
int tm_wday
Definition: time.h:83
int tm_yday
Definition: time.h:84
int tm_sec
Definition: time.h:77
int tm_hour
Definition: time.h:79
#define _CRT_WIDE(_String)
Definition: crtdefs.h:43
void _invalid_parameter(const wchar_t *expression, const wchar_t *function, const wchar_t *file, unsigned int line, uintptr_t pReserved)
Definition: errno.c:137

Referenced by _tctime_s().

◆ FillBuf()

static __inline void FillBuf ( timebuf_t buf,
const struct tm ptm 
)
static

Definition at line 78 of file asctime.c.

79 {
80  /* Format looks like this:
81  * "Sun Mar 01 12:34:56 1902\n\0" */
82  buf->WeekDay = *(_TCHAR4*)wday_name[ptm->tm_wday];
83  buf->Month = *(_TCHAR4*)mon_name[ptm->tm_mon];
84  buf->Day = IntToChar2(ptm->tm_mday);
85  buf->Space1 = ' ';
86  buf->Hour = IntToChar2(ptm->tm_hour);
87  buf->Sep1 = ':';
88  buf->Minute = IntToChar2(ptm->tm_min);
89  buf->Sep2 = ':';
90  buf->Second = IntToChar2(ptm->tm_sec);
91  buf->Space2 = ' ';
92  buf->Year[0] = IntToChar2(ptm->tm_year / 100 + HUNDREDYEAROFFSET);
93  buf->Year[1] = IntToChar2(ptm->tm_year % 100);
94  buf->lb = '\n';
95  buf->zt = '\0';
96 }
int tm_min
Definition: time.h:78
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
FORCEINLINE _TCHAR2 IntToChar2(int x)
Definition: asctime.c:62
#define HUNDREDYEAROFFSET
Definition: asctime.c:15
int tm_mday
Definition: time.h:80
int tm_year
Definition: time.h:82
unsigned long _TCHAR4
Definition: asctime.c:33
static const _TCHAR wday_name[DAYSPERWEEK][5]
Definition: asctime.c:17
int tm_mon
Definition: time.h:81
int tm_wday
Definition: time.h:83
static const _TCHAR mon_name[MONSPERYEAR][5]
Definition: asctime.c:23
int tm_sec
Definition: time.h:77
int tm_hour
Definition: time.h:79

Referenced by _tasctime(), and _tasctime_s().

◆ IntToChar2()

FORCEINLINE _TCHAR2 IntToChar2 ( int  x)

Definition at line 62 of file asctime.c.

63 {
64  union
65  {
66  _TCHAR2 char2;
67  _TCHAR array[2];
68  } u;
69 
70  u.array[0] = '0' + (x / 10);
71  u.array[1] = '0' + (x % 10);
72 
73  return u.char2;
74 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
unsigned short _TCHAR2
Definition: asctime.c:34
char _TCHAR
Definition: tchar.h:1392

Referenced by FillBuf().

Variable Documentation

◆ mon_name

const _TCHAR mon_name[MONSPERYEAR][5]
static
Initial value:
=
{
_T("Jan "), _T("Feb "), _T("Mar "), _T("Apr "), _T("May "), _T("Jun "),
_T("Jul "), _T("Aug "), _T("Sep "), _T("Oct "), _T("Nov "), _T("Dec ")
}
#define _T(x)
Definition: vfdio.h:22

Definition at line 23 of file asctime.c.

Referenced by FillBuf().

◆ wday_name

const _TCHAR wday_name[DAYSPERWEEK][5]
static
Initial value:
=
{
_T("Sun "), _T("Mon "), _T("Tue "), _T("Wed "),
_T("Thu "), _T("Fri "), _T("Sat ")
}
#define _T(x)
Definition: vfdio.h:22

Definition at line 17 of file asctime.c.

Referenced by FillBuf().