ReactOS  0.4.14-dev-606-g14ebc0b
systime.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS system libraries
4  * FILE: lib/sdk/crt/sys_stat/systime.c
5  * PURPOSE: Unknown
6  * PROGRAMER: Unknown
7  * UPDATE HISTORY:
8  * 25/11/05: Added license header
9  */
10 
11 #include <precomp.h>
12 
13 int month[12] = { 31,28,31,30,31,30,31,31,30,31,30,31};
14 
15 /*
16  * @unimplemented
17  */
18 unsigned int _getsystime(struct tm* tp)
19 {
21  int i;
22  DWORD TimeZoneId;
23  TIME_ZONE_INFORMATION TimeZoneInformation;
24 
26 
27  tp->tm_year = Time.wYear - 1900;
28  tp->tm_mon = Time.wMonth - 1;
29  tp->tm_wday = Time.wDayOfWeek;
30  tp->tm_mday = Time.wDay;
31  tp->tm_hour = Time.wHour;
32  tp->tm_min = Time.wMinute;
33  tp->tm_sec = Time.wSecond;
34 
35  tp->tm_isdst = -1;
36 
37  TimeZoneId = GetTimeZoneInformation(&TimeZoneInformation);
38  if (TimeZoneId == TIME_ZONE_ID_DAYLIGHT){
39  tp->tm_isdst = 1;
40  }
41  else
42  tp->tm_isdst = 0;
43 
44  if (tp->tm_year % 4 == 0) {
45  if (tp->tm_year % 100 != 0)
46  tp->tm_yday = 1;
47  else if ((tp->tm_year-100) % 1000 == 0)
48  tp->tm_yday = 1;
49  }
50 
51  for (i = 0; i <= tp->tm_mon; i++)
52  tp->tm_yday += month[i];
53 
54  return Time.wMilliseconds;
55 }
56 
57 
58 /*
59  * @implemented
60  */
61 unsigned int _setsystime(struct tm* tp, unsigned int ms)
62 {
64 
65  Time.wYear = tp->tm_year + 1900;
66  Time.wMonth = tp->tm_mon + 1;
67  Time.wDayOfWeek = tp->tm_wday;
68  Time.wDay = tp->tm_mday;
69  Time.wHour = tp->tm_hour;
70  Time.wMinute = tp->tm_min;
71  Time.wSecond = tp->tm_sec;
72  Time.wMilliseconds = ms;
73 
74  if (!SetLocalTime(&Time))
75  return -1;
76 
77  return 0;
78 }
DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
Definition: timezone.c:262
unsigned int _getsystime(struct tm *tp)
Definition: systime.c:18
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 const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2855
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: time.h:76
unsigned int _setsystime(struct tm *tp, unsigned int ms)
Definition: systime.c:61
int month[12]
Definition: systime.c:13
BOOL WINAPI SetLocalTime(IN CONST SYSTEMTIME *lpSystemTime)
Definition: time.c:356
#define TIME_ZONE_ID_DAYLIGHT
Definition: rtltypes.h:252
static PLARGE_INTEGER Time
Definition: time.c:105