ReactOS 0.4.16-dev-336-gb667d82
timezone.c File Reference
#include "precomp.h"
Include dependency graph for timezone.c:

Go to the source code of this file.

Functions

void__p__daylight (void)
 
long__p__timezone (void)
 
long__p__dstbias (void)
 
char ** __p__tzname (void)
 
void _tzset (void)
 
int CDECL _get_tzname (size_t *ret, char *buf, size_t bufsize, int index)
 

Variables

char _tz_is_set = 0
 
static char tz_name [64] = "PST"
 
static char tz_dst_name [64] = "PDT"
 
long dst_begin = 0
 
long dst_end = 0
 
char_tzname [2]
 
int _daylight = 0
 
long _timezone = 28800
 
long _dstbias = 0
 

Function Documentation

◆ __p__daylight()

void * __p__daylight ( void  )

Definition at line 37 of file timezone.c.

38{
39 return &_daylight;
40}
int _daylight
Definition: timezone.c:30

Referenced by Test__daylight().

◆ __p__dstbias()

long * __p__dstbias ( void  )

Definition at line 69 of file timezone.c.

70{
71 return &_dstbias;
72}
long _dstbias
Definition: timezone.c:62

Referenced by Test__dstbias().

◆ __p__timezone()

long * __p__timezone ( void  )

Definition at line 53 of file timezone.c.

54{
55 return &_timezone;
56}
long _timezone
Definition: timezone.c:46

Referenced by Test__timezone().

◆ __p__tzname()

char ** __p__tzname ( void  )

Definition at line 79 of file timezone.c.

80{
81 return _tzname;
82}
char * _tzname[2]
Definition: timezone.c:22

Referenced by Test__tzname().

◆ _get_tzname()

int CDECL _get_tzname ( size_t ret,
char buf,
size_t  bufsize,
int  index 
)

Definition at line 220 of file timezone.c.

221{
222 char *str_timezone;
223
224 switch (index)
225 {
226 case 0:
227 str_timezone = tz_name;
228 break;
229
230 case 1:
231 str_timezone = tz_dst_name;
232 break;
233
234 default:
235 *_errno() = EINVAL;
236 return EINVAL;
237 }
238
239 if (!ret || (!buf && (bufsize > 0)) || (buf && !bufsize))
240 {
241 *_errno() = EINVAL;
242 return EINVAL;
243 }
244
245 *ret = strlen(str_timezone) + 1;
246 if(!buf && !bufsize)
247 return 0;
248
249 strncpy(buf, str_timezone, bufsize);
250 return 0;
251}
#define EINVAL
Definition: acclib.h:90
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
GLuint index
Definition: glext.h:6031
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLuint GLsizei bufsize
Definition: glext.h:7473
_CRTIMP int *__cdecl _errno(void)
Definition: errno.c:17
static char tz_dst_name[64]
Definition: timezone.c:14
static char tz_name[64]
Definition: timezone.c:13
int ret

◆ _tzset()

void _tzset ( void  )

Definition at line 92 of file timezone.c.

93{
94 const char * str;
95
96 if (_tz_is_set)
97 {
98 return;
99 }
100
101 /* Try to read the timezone from environment */
102 str = getenv("TZ");
103 if (str && str[0] != 0)
104 {
105 long hour = 0, min = 0, sec = 0;
106 size_t len = strnlen(str, 16);
107 int sign = 1;
108
109 dst_begin = 0;
110
111 for (;;)
112 {
113 /* Copy timezone name */
114 strncpy(tz_name, str, 3);
115 str += 3;
116 len -= 3;
117
118 if (len < 1) break;
119
120 if (*str == '+' || *str == '-')
121 {
122 sign = *str == '-' ? -1 : 1;
123 str++;
124 len--;
125 }
126
127 if (len < 1) break;
128
129 hour = atol(str);
130
131 while (*str != 0 && *str != ':') str++;
132 if (*str == 0) break;
133
134 min = atol(++str);
135
136 while (*str != 0 && *str != ':') str++;
137 if (*str == 0) break;
138
139 sec = atol(++str);
140
141 while (*str != 0 && *str <= '9') str++;
142 if (*str == 0) break;
143
144 /* Copy DST name */
146
147 // FIXME: set dst_begin etc
148
149 /* We are finished */
150 break;
151 }
152
153 _timezone = sign * (((hour * 60) + min) * 60 + sec);
154
155 }
156 else
157 {
159 DWORD ret;
160
163 {
164 return;
165 }
166
168 0,
169 tzi.StandardName,
170 -1,
171 tz_name,
172 sizeof(tz_name),
173 NULL,
174 NULL);
175
177 0,
178 tzi.DaylightName,
179 -1,
181 sizeof(tz_dst_name),
182 NULL,
183 NULL);
184
185 _timezone = tzi.Bias * 60;
186
187 if (tzi.DaylightDate.wMonth)
188 {
189 struct tm _tm;
190
191 _daylight = 1;
192 _dstbias = (tzi.DaylightBias - tzi.StandardBias) * 60;
193 _tm.tm_year = 70;
194 _tm.tm_mon = tzi.DaylightDate.wMonth - 1;
195 _tm.tm_mday = tzi.DaylightDate.wDay;
196 _tm.tm_hour = tzi.DaylightDate.wHour;
197 _tm.tm_min = tzi.DaylightDate.wMinute;
198 _tm.tm_sec = tzi.DaylightDate.wSecond;
199 dst_begin = (long)_mkgmtime(&_tm);
200 _tm.tm_mon = tzi.StandardDate.wMonth - 1;
201 _tm.tm_mday = tzi.StandardDate.wDay;
202 _tm.tm_hour = tzi.StandardDate.wHour;
203 _tm.tm_min = tzi.StandardDate.wMinute;
204 _tm.tm_sec = tzi.StandardDate.wSecond;
205 dst_end = (long)_mkgmtime(&_tm);
206 }
207 else
208 {
209 _daylight = 0;
210 _dstbias = 0;
211 }
212
213 }
214 _tz_is_set = 1;
215}
#define NULL
Definition: types.h:112
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
Definition: timezone.c:262
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
#define sign(x)
Definition: mapdesc.cc:613
#define min(a, b)
Definition: monoChain.cc:55
#define long
Definition: qsort.c:33
const WCHAR * str
_CRTIMP time_t __cdecl _mkgmtime(struct tm *_Tm)
Definition: time.h:419
long dst_begin
Definition: timezone.c:16
long dst_end
Definition: timezone.c:17
char _tz_is_set
Definition: timezone.c:10
WORD wMonth
Definition: winbase.h:931
WORD wHour
Definition: winbase.h:934
WORD wSecond
Definition: winbase.h:936
WORD wMinute
Definition: winbase.h:935
WORD wDay
Definition: winbase.h:933
SYSTEMTIME DaylightDate
Definition: winbase.h:1236
WCHAR DaylightName[32]
Definition: winbase.h:1235
WCHAR StandardName[32]
Definition: winbase.h:1232
SYSTEMTIME StandardDate
Definition: winbase.h:1233
Definition: time.h:68
#define TIME_ZONE_ID_INVALID
Definition: winbase.h:312

Referenced by _Strftime(), gettimeofday(), localtime(), and test__tzset().

Variable Documentation

◆ _daylight

int _daylight = 0

Definition at line 30 of file timezone.c.

Referenced by __p__daylight(), _tzset(), gettimeofday(), and Test__daylight().

◆ _dstbias

long _dstbias = 0

Definition at line 62 of file timezone.c.

Referenced by __p__dstbias(), _gmtime_worker(), _tzset(), localtime(), and Test__dstbias().

◆ _timezone

long _timezone = 28800

Definition at line 46 of file timezone.c.

Referenced by __p__timezone(), _tzset(), gettimeofday(), localtime(), and Test__timezone().

◆ _tz_is_set

char _tz_is_set = 0

Definition at line 10 of file timezone.c.

Referenced by _tzset(), and localtime().

◆ _tzname

char* _tzname[2]
Initial value:

Definition at line 22 of file timezone.c.

Referenced by __p__tzname(), and Test__tzname().

◆ dst_begin

long dst_begin = 0

Definition at line 16 of file timezone.c.

Referenced by _gmtime_worker(), and _tzset().

◆ dst_end

◆ tz_dst_name

char tz_dst_name[64] = "PDT"
static

Definition at line 14 of file timezone.c.

Referenced by _get_tzname(), and _tzset().

◆ tz_name

char tz_name[64] = "PST"
static

Definition at line 13 of file timezone.c.

Referenced by _get_tzname(), and _tzset().