ReactOS 0.4.16-dev-2104-gb84fa49
time.c
Go to the documentation of this file.
1/*
2 * msvcrt.dll date/time functions
3 *
4 * Copyright 1996,1998 Marcus Meissner
5 * Copyright 1996 Jukka Iivonen
6 * Copyright 1997,2000 Uwe Bonnes
7 * Copyright 2000 Jon Griffiths
8 * Copyright 2004 Hans Leidekker
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <locale.h>
26#include <stdlib.h>
27#include <time.h>
28#include <sys/timeb.h>
29
30#include "msvcrt.h"
31#include "mtdll.h"
32#include "winbase.h"
33#include "winnls.h"
34#include "winternl.h"
35#include "wine/debug.h"
36
38
39#undef _ctime32
40#undef _difftime32
41#undef _gmtime32
42#undef _localtime32
43#undef _mktime32
44#undef _time32
45#undef _wctime32
46
48
50{
51 LARGE_INTEGER systime;
52
53 NtQuerySystemTime(&systime);
54 init_time = systime.QuadPart;
55}
56
57static const int MonthLengths[2][12] =
58{
59 { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
60 { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
61};
62
63#if _MSVCR_VER>=140
64static const int MAX_SECONDS = 60;
65#else
66static const int MAX_SECONDS = 59;
67#endif
68
69#if _MSVCR_VER == 0
70#define MIN_GMTIME64_TIME 0
71#define MAX_GMTIME64_TIME _MAX__TIME64_T
72#elif _MSVCR_VER >= 140
73#define MIN_GMTIME64_TIME -43200
74#define MAX_GMTIME64_TIME (_MAX__TIME64_T + 1605600)
75#else
76#define MIN_GMTIME64_TIME -43200
77#define MAX_GMTIME64_TIME (_MAX__TIME64_T + 46800)
78#endif
79
80static inline BOOL IsLeapYear(int Year)
81{
82 return Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0);
83}
84
85static inline void write_invalid_msvcrt_tm( struct tm *tm )
86{
87 tm->tm_sec = -1;
88 tm->tm_min = -1;
89 tm->tm_hour = -1;
90 tm->tm_mday = -1;
91 tm->tm_mon = -1;
92 tm->tm_year = -1;
93 tm->tm_wday = -1;
94 tm->tm_yday = -1;
95 tm->tm_isdst = -1;
96}
97
98/*********************************************************************
99 * _daylight (MSVCRT.@)
100 */
102
103/*********************************************************************
104 * _timezone (MSVCRT.@)
105 */
107
108/*********************************************************************
109 * _dstbias (MSVCRT.@)
110 */
112
113/*********************************************************************
114 * _tzname (MSVCRT.@)
115 * NOTES
116 * Some apps (notably Mozilla) insist on writing to these, so the buffer
117 * must be large enough.
118 */
119static char tzname_std[64] = "PST";
120static char tzname_dst[64] = "PDT";
122
124/*********************************************************************
125 * _tzset (MSVCRT.@)
126 */
127void CDECL _tzset(void)
128{
129 char *tz = getenv("TZ");
130 BOOL error;
131
133 if(tz && tz[0]) {
134 BOOL neg_zone = FALSE;
135
136 memset(&tzi, 0, sizeof(tzi));
137
138 /* Parse timezone information: tzn[+|-]hh[:mm[:ss]][dzn] */
140 tz += 3;
141
142 if(*tz == '-') {
143 neg_zone = TRUE;
144 tz++;
145 }else if(*tz == '+') {
146 tz++;
147 }
148 MSVCRT___timezone = strtol(tz, &tz, 10)*3600;
149 if(*tz == ':') {
150 MSVCRT___timezone += strtol(tz+1, &tz, 10)*60;
151 if(*tz == ':')
152 MSVCRT___timezone += strtol(tz+1, &tz, 10);
153 }
154 if(neg_zone)
156
163
167 }else {
169 MSVCRT__dstbias = 0;
170 }
171
173 sizeof(tzname_std), NULL, &error) || error)
174 *MSVCRT__tzname[0] = 0;
176 sizeof(tzname_dst), NULL, &error) || error)
177 *MSVCRT__tzname[0] = 0;
178 }
180}
181
182static void _tzset_init(void)
183{
184 static BOOL init = FALSE;
185
186 if(!init) {
188 if(!init) {
189 _tzset();
190 init = TRUE;
191 }
193 }
194}
195
196static BOOL is_dst(const SYSTEMTIME *st)
197{
200
202 return FALSE;
203
205 tmp = tzi;
206 }else if(st->wYear >= 2007) {
207 memset(&tmp, 0, sizeof(tmp));
208 tmp.StandardDate.wMonth = 11;
209 tmp.StandardDate.wDay = 1;
210 tmp.StandardDate.wHour = 2;
211 tmp.DaylightDate.wMonth = 3;
212 tmp.DaylightDate.wDay = 2;
213 tmp.DaylightDate.wHour = 2;
214 }else {
215 memset(&tmp, 0, sizeof(tmp));
216 tmp.StandardDate.wMonth = 10;
217 tmp.StandardDate.wDay = 5;
218 tmp.StandardDate.wHour = 2;
219 tmp.DaylightDate.wMonth = 4;
220 tmp.DaylightDate.wDay = 1;
221 tmp.DaylightDate.wHour = 2;
222 }
223
224 tmp.Bias = 0;
225 tmp.StandardBias = 0;
227 if(!SystemTimeToTzSpecificLocalTime(&tmp, st, &out))
228 return FALSE;
229
230 return memcmp(st, &out, sizeof(SYSTEMTIME));
231}
232
233#define SECSPERDAY 86400
234/* 1601 to 1970 is 369 years plus 89 leap days */
235#define SECS_1601_TO_1970 ((369 * 365 + 89) * (ULONGLONG)SECSPERDAY)
236#define TICKSPERSEC 10000000
237#define TICKSPERMSEC 10000
238#define TICKS_1601_TO_1970 (SECS_1601_TO_1970 * TICKSPERSEC)
239
240static __time64_t mktime_helper(struct tm *mstm, BOOL local)
241{
242 SYSTEMTIME st;
243 FILETIME ft;
244 __time64_t ret = 0;
245 int i;
246 BOOL use_dst = FALSE;
247
248 ret = mstm->tm_year + mstm->tm_mon/12;
249 mstm->tm_mon %= 12;
250 if(mstm->tm_mon < 0) {
251 mstm->tm_mon += 12;
252 ret--;
253 }
254
255 if(ret<70 || ret>1100) {
256 *_errno() = EINVAL;
257 return -1;
258 }
259
260 memset(&st, 0, sizeof(SYSTEMTIME));
261 st.wDay = 1;
262 st.wMonth = mstm->tm_mon+1;
263 st.wYear = ret+1900;
264
265 if(!SystemTimeToFileTime(&st, &ft)) {
266 *_errno() = EINVAL;
267 return -1;
268 }
269
272 ret += (__time64_t)mstm->tm_min*60*TICKSPERSEC;
273 ret += (__time64_t)mstm->tm_hour*60*60*TICKSPERSEC;
275
276 ft.dwLowDateTime = ret & 0xffffffff;
277 ft.dwHighDateTime = ret >> 32;
278 FileTimeToSystemTime(&ft, &st);
279
280 if(local) {
281 _tzset_init();
282 use_dst = is_dst(&st);
283 if((mstm->tm_isdst<=-1 && use_dst) || (mstm->tm_isdst>=1)) {
284 SYSTEMTIME tmp;
285
287
288 ft.dwLowDateTime = ret & 0xffffffff;
289 ft.dwHighDateTime = ret >> 32;
290 FileTimeToSystemTime(&ft, &tmp);
291
292 if(!is_dst(&tmp)) {
293 st = tmp;
294 use_dst = FALSE;
295 }else {
296 use_dst = TRUE;
297 }
298 }else if(mstm->tm_isdst==0 && use_dst) {
300 ft.dwLowDateTime = ret & 0xffffffff;
301 ft.dwHighDateTime = ret >> 32;
302 FileTimeToSystemTime(&ft, &st);
304 }
306 }
307
308 mstm->tm_sec = st.wSecond;
309 mstm->tm_min = st.wMinute;
310 mstm->tm_hour = st.wHour;
311 mstm->tm_mday = st.wDay;
312 mstm->tm_mon = st.wMonth-1;
313 mstm->tm_year = st.wYear-1900;
314 mstm->tm_wday = st.wDayOfWeek;
315 for(i=mstm->tm_yday=0; i<st.wMonth-1; i++)
316 mstm->tm_yday += MonthLengths[IsLeapYear(st.wYear)][i];
317 mstm->tm_yday += st.wDay-1;
318 mstm->tm_isdst = use_dst ? 1 : 0;
319
320 if(ret < TICKS_1601_TO_1970) {
321 *_errno() = EINVAL;
322 return -1;
323 }
325 return ret;
326}
327
328/**********************************************************************
329 * _mktime64 (MSVCRT.@)
330 */
332{
333 return mktime_helper(mstm, TRUE);
334}
335
336/**********************************************************************
337 * _mktime32 (MSVCRT.@)
338 */
340{
341 __time64_t ret = _mktime64( mstm );
342 return ret == (__time32_t)ret ? ret : -1;
343}
344
345/**********************************************************************
346 * _mkgmtime64 (MSVCRT.@)
347 *
348 * time->tm_isdst value is ignored
349 */
351{
352 return mktime_helper(time, FALSE);
353}
354
355/**********************************************************************
356 * _mkgmtime32 (MSVCRT.@)
357 */
359{
361 return ret == (__time32_t)ret ? ret : -1;
362}
363
364/*********************************************************************
365 * _localtime64_s (MSVCRT.@)
366 */
367int CDECL _localtime64_s(struct tm *res, const __time64_t *secs)
368{
369 int i;
370 FILETIME ft;
371 SYSTEMTIME st;
373
374 if (!res || !secs || *secs < 0 || *secs > _MAX__TIME64_T)
375 {
376 if (res)
378
379 *_errno() = EINVAL;
380 return EINVAL;
381 }
382
383 _tzset_init();
385
386 ft.dwHighDateTime = (UINT)(time >> 32);
387 ft.dwLowDateTime = (UINT)time;
388 FileTimeToSystemTime(&ft, &st);
389
390 res->tm_isdst = is_dst(&st) ? 1 : 0;
391 if(res->tm_isdst) {
393 ft.dwHighDateTime = (UINT)(time >> 32);
394 ft.dwLowDateTime = (UINT)time;
395 FileTimeToSystemTime(&ft, &st);
396 }
397
398 res->tm_sec = st.wSecond;
399 res->tm_min = st.wMinute;
400 res->tm_hour = st.wHour;
401 res->tm_mday = st.wDay;
402 res->tm_year = st.wYear - 1900;
403 res->tm_mon = st.wMonth - 1;
404 res->tm_wday = st.wDayOfWeek;
405 for (i = res->tm_yday = 0; i < st.wMonth - 1; i++)
406 res->tm_yday += MonthLengths[IsLeapYear(st.wYear)][i];
407 res->tm_yday += st.wDay - 1;
408
409 return 0;
410}
411
412/*********************************************************************
413 * _localtime64 (MSVCRT.@)
414 */
415struct tm* CDECL _localtime64(const __time64_t* secs)
416{
418
419 if(!data->time_buffer)
420 data->time_buffer = malloc(sizeof(struct tm));
421
422 if(_localtime64_s(data->time_buffer, secs))
423 return NULL;
424 return data->time_buffer;
425}
426
427/*********************************************************************
428 * _localtime32 (MSVCRT.@)
429 */
430struct tm* CDECL _localtime32(const __time32_t* secs)
431{
432 __time64_t secs64;
433
434 if(!secs)
435 return NULL;
436
437 secs64 = *secs;
438 return _localtime64( &secs64 );
439}
440
441/*********************************************************************
442 * _localtime32_s (MSVCRT.@)
443 */
444int CDECL _localtime32_s(struct tm *time, const __time32_t *secs)
445{
446 __time64_t secs64;
447
448 if (!time || !secs || *secs < 0)
449 {
450 if (time)
452
453 *_errno() = EINVAL;
454 return EINVAL;
455 }
456
457 secs64 = *secs;
458 return _localtime64_s(time, &secs64);
459}
460
461/*********************************************************************
462 * _gmtime64 (MSVCRT.@)
463 */
464int CDECL _gmtime64_s(struct tm *res, const __time64_t *secs)
465{
466 int i;
467 FILETIME ft;
468 SYSTEMTIME st;
470
471 TRACE("res %p, secs %p (%I64d).\n", res, secs, secs ? *secs : 0);
472
473 if (!res || !secs || *secs < MIN_GMTIME64_TIME || *secs > MAX_GMTIME64_TIME) {
474 if (res) {
476 }
477
478 *_errno() = EINVAL;
479 return EINVAL;
480 }
481
483
484 ft.dwHighDateTime = (UINT)(time >> 32);
485 ft.dwLowDateTime = (UINT)time;
486
487 FileTimeToSystemTime(&ft, &st);
488
489 res->tm_sec = st.wSecond;
490 res->tm_min = st.wMinute;
491 res->tm_hour = st.wHour;
492 res->tm_mday = st.wDay;
493 res->tm_year = st.wYear - 1900;
494 res->tm_mon = st.wMonth - 1;
495 res->tm_wday = st.wDayOfWeek;
496 for (i = res->tm_yday = 0; i < st.wMonth - 1; i++) {
497 res->tm_yday += MonthLengths[IsLeapYear(st.wYear)][i];
498 }
499
500 res->tm_yday += st.wDay - 1;
501 res->tm_isdst = 0;
502
503 return 0;
504}
505
506/*********************************************************************
507 * _gmtime64 (MSVCRT.@)
508 */
509struct tm* CDECL _gmtime64(const __time64_t *secs)
510{
512
513 if(!data->time_buffer)
514 data->time_buffer = malloc(sizeof(struct tm));
515
516 if(_gmtime64_s(data->time_buffer, secs))
517 return NULL;
518 return data->time_buffer;
519}
520
521/*********************************************************************
522 * _gmtime32_s (MSVCRT.@)
523 */
524int CDECL _gmtime32_s(struct tm *res, const __time32_t *secs)
525{
526 __time64_t secs64;
527
528 if(secs) {
529 secs64 = *secs;
530 return _gmtime64_s(res, &secs64);
531 }
532 return _gmtime64_s(res, NULL);
533}
534
535/*********************************************************************
536 * _gmtime32 (MSVCRT.@)
537 */
538struct tm* CDECL _gmtime32(const __time32_t* secs)
539{
540 __time64_t secs64;
541
542 if(!secs)
543 return NULL;
544
545 secs64 = *secs;
546 return _gmtime64( &secs64 );
547}
548
549/**********************************************************************
550 * _strdate (MSVCRT.@)
551 */
552char* CDECL _strdate(char* date)
553{
554 SYSTEMTIME st;
555
556 GetLocalTime(&st);
557 date[0] = '0' + st.wMonth / 10;
558 date[1] = '0' + st.wMonth % 10;
559 date[2] = '/';
560 date[3] = '0' + st.wDay / 10;
561 date[4] = '0' + st.wDay % 10;
562 date[5] = '/';
563 date[6] = '0' + st.wYear / 10 % 10;
564 date[7] = '0' + st.wYear % 10;
565 date[8] = 0;
566 return date;
567}
568
569/**********************************************************************
570 * _strdate_s (MSVCRT.@)
571 */
572int CDECL _strdate_s(char* date, size_t size)
573{
574 if(date && size)
575 date[0] = '\0';
576
577 if(!date) {
578 *_errno() = EINVAL;
579 return EINVAL;
580 }
581
582 if(size < 9) {
583 *_errno() = ERANGE;
584 return ERANGE;
585 }
586
587 _strdate(date);
588 return 0;
589}
590
591/**********************************************************************
592 * _wstrdate (MSVCRT.@)
593 */
594wchar_t* CDECL _wstrdate(wchar_t* date)
595{
596 GetDateFormatW(LOCALE_NEUTRAL, 0, NULL, L"MM'/'dd'/'yy", date, 9);
597 return date;
598}
599
600/**********************************************************************
601 * _wstrdate_s (MSVCRT.@)
602 */
603int CDECL _wstrdate_s(wchar_t* date, size_t size)
604{
605 if(date && size)
606 date[0] = '\0';
607
608 if(!date) {
609 *_errno() = EINVAL;
610 return EINVAL;
611 }
612
613 if(size < 9) {
614 *_errno() = ERANGE;
615 return ERANGE;
616 }
617
619 return 0;
620}
621
622/*********************************************************************
623 * _strtime (MSVCRT.@)
624 */
625char* CDECL _strtime(char* time)
626{
627 SYSTEMTIME st;
628
629 GetLocalTime(&st);
630 time[0] = '0' + st.wHour / 10;
631 time[1] = '0' + st.wHour % 10;
632 time[2] = ':';
633 time[3] = '0' + st.wMinute / 10;
634 time[4] = '0' + st.wMinute % 10;
635 time[5] = ':';
636 time[6] = '0' + st.wSecond / 10;
637 time[7] = '0' + st.wSecond % 10;
638 time[8] = 0;
639 return time;
640}
641
642/*********************************************************************
643 * _strtime_s (MSVCRT.@)
644 */
645int CDECL _strtime_s(char* time, size_t size)
646{
647 if(time && size)
648 time[0] = '\0';
649
650 if(!time) {
651 *_errno() = EINVAL;
652 return EINVAL;
653 }
654
655 if(size < 9) {
656 *_errno() = ERANGE;
657 return ERANGE;
658 }
659
660 _strtime(time);
661 return 0;
662}
663
664/*********************************************************************
665 * _wstrtime (MSVCRT.@)
666 */
667wchar_t* CDECL _wstrtime(wchar_t* time)
668{
669 GetTimeFormatW(LOCALE_NEUTRAL, 0, NULL, L"HH':'mm':'ss", time, 9);
670 return time;
671}
672
673/*********************************************************************
674 * _wstrtime_s (MSVCRT.@)
675 */
676int CDECL _wstrtime_s(wchar_t* time, size_t size)
677{
678 if(time && size)
679 time[0] = '\0';
680
681 if(!time) {
682 *_errno() = EINVAL;
683 return EINVAL;
684 }
685
686 if(size < 9) {
687 *_errno() = ERANGE;
688 return ERANGE;
689 }
690
692 return 0;
693}
694
695/*********************************************************************
696 * clock (MSVCRT.@)
697 */
699{
700 LARGE_INTEGER systime;
701
702 NtQuerySystemTime(&systime);
703 return (systime.QuadPart - init_time) / (TICKSPERSEC / CLOCKS_PER_SEC);
704}
705
706/*********************************************************************
707 * _difftime64 (MSVCRT.@)
708 */
710{
711 return (double)(time1 - time2);
712}
713
714/*********************************************************************
715 * _difftime32 (MSVCRT.@)
716 */
718{
719 return (double)(time1 - time2);
720}
721
722/*********************************************************************
723 * _ftime64 (MSVCRT.@)
724 */
726{
728 FILETIME ft;
730
731 _tzset_init();
732
734
735 time = ((ULONGLONG)ft.dwHighDateTime << 32) | ft.dwLowDateTime;
736
738 buf->millitm = (time % TICKSPERSEC) / TICKSPERMSEC;
739 buf->timezone = MSVCRT___timezone / 60;
740 buf->dstflag = GetTimeZoneInformation( &tzinfo) == TIME_ZONE_ID_DAYLIGHT;
741}
742
743/*********************************************************************
744 * _ftime64_s (MSVCRT.@)
745 */
747{
748 if (!MSVCRT_CHECK_PMT( buf != NULL )) return EINVAL;
749 _ftime64(buf);
750 return 0;
751}
752
753/*********************************************************************
754 * _ftime32 (MSVCRT.@)
755 */
757{
758 struct __timeb64 buf64;
759
760 _ftime64( &buf64 );
761 buf->time = buf64.time;
762 buf->millitm = buf64.millitm;
763 buf->timezone = buf64.timezone;
764 buf->dstflag = buf64.dstflag;
765}
766
767/*********************************************************************
768 * _ftime32_s (MSVCRT.@)
769 */
771{
772 if (!MSVCRT_CHECK_PMT( buf != NULL )) return EINVAL;
773 _ftime32(buf);
774 return 0;
775}
776
777/*********************************************************************
778 * _time64 (MSVCRT.@)
779 */
781{
782 __time64_t curtime;
783 struct __timeb64 tb;
784
785 _ftime64(&tb);
786
787 curtime = tb.time;
788 return buf ? *buf = curtime : curtime;
789}
790
791/*********************************************************************
792 * _time32 (MSVCRT.@)
793 */
795{
796 __time32_t curtime;
797 struct __timeb64 tb;
798
799 _ftime64(&tb);
800
801 curtime = tb.time;
802 return buf ? *buf = curtime : curtime;
803}
804
805/*********************************************************************
806 * __p__daylight (MSVCRT.@)
807 */
809{
810 return &MSVCRT___daylight;
811}
812
813/*********************************************************************
814 * __p__dstbias (MSVCRT.@)
815 */
817{
818 return &MSVCRT__dstbias;
819}
820
821#if _MSVCR_VER >= 80
822/*********************************************************************
823 * _get_dstbias (MSVCR80.@)
824 */
825int CDECL _get_dstbias(int *seconds)
826{
827 if (!MSVCRT_CHECK_PMT(seconds != NULL)) return EINVAL;
828 *seconds = MSVCRT__dstbias;
829 return 0;
830}
831#endif
832
833/*********************************************************************
834 * __p__timezone (MSVCRT.@)
835 */
837{
838 return &MSVCRT___timezone;
839}
840
841/*********************************************************************
842 * _get_tzname (MSVCRT.@)
843 */
844int CDECL _get_tzname(size_t *ret, char *buf, size_t bufsize, int index)
845{
846 char *timezone;
847
848 switch(index)
849 {
850 case 0:
852 break;
853 case 1:
855 break;
856 default:
857 *_errno() = EINVAL;
858 return EINVAL;
859 }
860
861 if(!ret || (!buf && bufsize > 0) || (buf && !bufsize))
862 {
863 *_errno() = EINVAL;
864 return EINVAL;
865 }
866
867 *ret = strlen(timezone)+1;
868 if(!buf && !bufsize)
869 return 0;
870 if(*ret > bufsize)
871 {
872 buf[0] = 0;
873 return ERANGE;
874 }
875
877 return 0;
878}
879
880/*********************************************************************
881 * __p_tzname (MSVCRT.@)
882 */
883char ** CDECL __p__tzname(void)
884{
885 return MSVCRT__tzname;
886}
887
888#if _MSVCR_VER <= 90
889#define STRFTIME_CHAR char
890#define STRFTIME_TD(td, name) td->str.names.name
891#else
892#define STRFTIME_CHAR wchar_t
893#define STRFTIME_TD(td, name) td->wstr.names.name
894#endif
895
896#define strftime_str(a,b,c,d) strftime_nstr(a,b,c,d,SIZE_MAX)
897static inline BOOL strftime_nstr(STRFTIME_CHAR *str, size_t *pos,
898 size_t max, const STRFTIME_CHAR *src, size_t len)
899{
900 while(*src && len)
901 {
902 if(*pos >= max) {
903 *str = 0;
904 *_errno() = ERANGE;
905 return FALSE;
906 }
907
908 str[*pos] = *src;
909 src++;
910 *pos += 1;
911 len--;
912 }
913 return TRUE;
914}
915
916static inline BOOL strftime_int(STRFTIME_CHAR *str, size_t *pos, size_t max,
917 int src, int prec, int l, int h)
918{
919 size_t len;
920
921 if(!MSVCRT_CHECK_PMT(src>=l && src<=h)) {
922 *str = 0;
923 return FALSE;
924 }
925
926#if _MSVCR_VER <= 90
927 len = _snprintf(str+*pos, max-*pos, "%0*d", prec, src);
928#else
929 len = _snwprintf(str+*pos, max-*pos, L"%0*d", prec, src);
930#endif
931 if(len == -1) {
932 *str = 0;
933 *_errno() = ERANGE;
934 return FALSE;
935 }
936
937 *pos += len;
938 return TRUE;
939}
940
941static inline BOOL strftime_format(STRFTIME_CHAR *str, size_t *pos, size_t max,
942 const struct tm *mstm, __lc_time_data *time_data, const STRFTIME_CHAR *format)
943{
944 size_t count;
945 BOOL ret = TRUE;
946
947 while(*format && ret)
948 {
949 count = 1;
950 while(format[0] == format[count]) count++;
951
952 switch(*format) {
953 case '\'':
954 if(count % 2 == 0) break;
955
956 format += count;
957 count = 0;
958 while(format[count] && format[count] != '\'') count++;
959
961 if(!ret) return FALSE;
962 if(format[count] == '\'') count++;
963 break;
964 case 'd':
965 if(count > 2)
966 {
967 if(!MSVCRT_CHECK_PMT(mstm->tm_wday>=0 && mstm->tm_wday<=6))
968 {
969 *str = 0;
970 return FALSE;
971 }
972 }
973 switch(count) {
974 case 1:
975 case 2:
976 ret = strftime_int(str, pos, max, mstm->tm_mday, count==1 ? 0 : 2, 1, 31);
977 break;
978 case 3:
979 ret = strftime_str(str, pos, max, STRFTIME_TD(time_data, short_wday)[mstm->tm_wday]);
980 break;
981 default:
983 if(ret)
984 ret = strftime_str(str, pos, max, STRFTIME_TD(time_data, wday)[mstm->tm_wday]);
985 break;
986 }
987 break;
988 case 'M':
989 if(count > 2)
990 {
991 if(!MSVCRT_CHECK_PMT(mstm->tm_mon>=0 && mstm->tm_mon<=11))
992 {
993 *str = 0;
994 return FALSE;
995 }
996 }
997 switch(count) {
998 case 1:
999 case 2:
1000 ret = strftime_int(str, pos, max, mstm->tm_mon+1, count==1 ? 0 : 2, 1, 12);
1001 break;
1002 case 3:
1003 ret = strftime_str(str, pos, max, STRFTIME_TD(time_data, short_mon)[mstm->tm_mon]);
1004 break;
1005 default:
1007 if(ret)
1008 ret = strftime_str(str, pos, max, STRFTIME_TD(time_data, mon)[mstm->tm_mon]);
1009 break;
1010 }
1011 break;
1012 case 'y':
1013 if(count > 1)
1014 {
1015#if _MSVCR_VER>=140
1016 if(!MSVCRT_CHECK_PMT(mstm->tm_year >= -1900 && mstm->tm_year <= 8099))
1017#else
1018 if(!MSVCRT_CHECK_PMT(mstm->tm_year >= 0))
1019#endif
1020 {
1021 *str = 0;
1022 return FALSE;
1023 }
1024 }
1025
1026 switch(count) {
1027 case 1:
1028 ret = strftime_nstr(str, pos, max, format, 1);
1029 break;
1030 case 2:
1031 case 3:
1033 if(ret)
1034 ret = strftime_int(str, pos, max, (mstm->tm_year+1900)%100, 2, 0, 99);
1035 break;
1036 default:
1038 if(ret)
1039 ret = strftime_int(str, pos, max, mstm->tm_year+1900, 4, 0, 9999);
1040 break;
1041 }
1042 break;
1043 case 'h':
1044 if(!MSVCRT_CHECK_PMT(mstm->tm_hour>=0 && mstm->tm_hour<=23))
1045 {
1046 *str = 0;
1047 return FALSE;
1048 }
1049 if(count > 2)
1051 if(ret)
1052 ret = strftime_int(str, pos, max, (mstm->tm_hour + 11) % 12 + 1,
1053 count == 1 ? 0 : 2, 1, 12);
1054 break;
1055 case 'H':
1056 if(count > 2)
1058 if(ret)
1059 ret = strftime_int(str, pos, max, mstm->tm_hour, count == 1 ? 0 : 2, 0, 23);
1060 break;
1061 case 'm':
1062 if(count > 2)
1064 if(ret)
1065 ret = strftime_int(str, pos, max, mstm->tm_min, count == 1 ? 0 : 2, 0, 59);
1066 break;
1067 case 's':
1068 if(count > 2)
1070 if(ret)
1071 ret = strftime_int(str, pos, max, mstm->tm_sec, count == 1 ? 0 : 2, 0, MAX_SECONDS);
1072 break;
1073 case 'a':
1074 case 'A':
1075 case 't':
1076 if(!MSVCRT_CHECK_PMT(mstm->tm_hour>=0 && mstm->tm_hour<=23))
1077 {
1078 *str = 0;
1079 return FALSE;
1080 }
1082 mstm->tm_hour < 12 ? STRFTIME_TD(time_data, am) : STRFTIME_TD(time_data, pm),
1083 (*format == 't' && count == 1) ? 1 : SIZE_MAX);
1084 break;
1085 default:
1087 break;
1088 }
1089 format += count;
1090 }
1091
1092 return ret;
1093}
1094
1095#if _MSVCR_VER>=140
1096static inline BOOL strftime_tzdiff(STRFTIME_CHAR *str, size_t *pos, size_t max, BOOL is_dst)
1097{
1099 char sign;
1100
1101 if(tz < 0) {
1102 sign = '+';
1103 tz = -tz;
1104 }else {
1105 sign = '-';
1106 }
1107
1108 if(*pos < max)
1109 str[(*pos)++] = sign;
1110 if(!strftime_int(str, pos, max, tz/60/60, 2, 0, 99))
1111 return FALSE;
1112 return strftime_int(str, pos, max, tz/60%60, 2, 0, 59);
1113}
1114#endif
1115
1116static size_t strftime_impl(STRFTIME_CHAR *str, size_t max,
1117 const STRFTIME_CHAR *format, const struct tm *mstm,
1118 __lc_time_data *time_data, _locale_t loc)
1119{
1120 size_t ret, tmp;
1121 BOOL alternate;
1122 int year = mstm ? mstm->tm_year + 1900 : -1;
1123
1124 if(!str || !format) {
1125 if(str && max)
1126 *str = 0;
1127 *_errno() = EINVAL;
1128 return 0;
1129 }
1130
1131 if(!time_data)
1132 time_data = loc ? loc->locinfo->lc_time_curr : get_locinfo()->lc_time_curr;
1133
1134 for(ret=0; *format && ret<max; format++) {
1135 if(*format != '%') {
1136 if(_isleadbyte_l((unsigned char)*format, loc)) {
1137 str[ret++] = *(format++);
1138 if(ret == max) continue;
1139 if(!MSVCRT_CHECK_PMT(str[ret]))
1140 goto einval_error;
1141 }
1142 str[ret++] = *format;
1143 continue;
1144 }
1145
1146 format++;
1147 if(*format == '#') {
1148 alternate = TRUE;
1149 format++;
1150 }else {
1151 alternate = FALSE;
1152 }
1153
1154 if(!MSVCRT_CHECK_PMT(mstm))
1155 goto einval_error;
1156
1157 switch(*format) {
1158 case 'c':
1159#if _MSVCR_VER>=140
1160 if(time_data == &cloc_time_data && !alternate)
1161 {
1162 tmp = strftime_impl(str+ret, max-ret, L"%a %b %e %T %Y", mstm, time_data, loc);
1163 if(!tmp)
1164 return 0;
1165 ret += tmp;
1166 break;
1167 }
1168#endif
1169 if(!strftime_format(str, &ret, max, mstm, time_data,
1170 alternate ? STRFTIME_TD(time_data, date) : STRFTIME_TD(time_data, short_date)))
1171 return 0;
1172 if(ret < max)
1173 str[ret++] = ' ';
1174 if(!strftime_format(str, &ret, max, mstm, time_data, STRFTIME_TD(time_data, time)))
1175 return 0;
1176 break;
1177 case 'x':
1178 if(!strftime_format(str, &ret, max, mstm, time_data,
1179 alternate ? STRFTIME_TD(time_data, date) : STRFTIME_TD(time_data, short_date)))
1180 return 0;
1181 break;
1182 case 'X':
1183 if(!strftime_format(str, &ret, max, mstm, time_data, STRFTIME_TD(time_data, time)))
1184 return 0;
1185 break;
1186 case 'a':
1187 if(!MSVCRT_CHECK_PMT(mstm->tm_wday>=0 && mstm->tm_wday<=6))
1188 goto einval_error;
1189 if(!strftime_str(str, &ret, max, STRFTIME_TD(time_data, short_wday)[mstm->tm_wday]))
1190 return 0;
1191 break;
1192 case 'A':
1193 if(!MSVCRT_CHECK_PMT(mstm->tm_wday>=0 && mstm->tm_wday<=6))
1194 goto einval_error;
1195 if(!strftime_str(str, &ret, max, STRFTIME_TD(time_data, wday)[mstm->tm_wday]))
1196 return 0;
1197 break;
1198 case 'b':
1199#if _MSVCR_VER>=140
1200 case 'h':
1201#endif
1202 if(!MSVCRT_CHECK_PMT(mstm->tm_mon>=0 && mstm->tm_mon<=11))
1203 goto einval_error;
1204 if(!strftime_str(str, &ret, max, STRFTIME_TD(time_data, short_mon)[mstm->tm_mon]))
1205 return 0;
1206 break;
1207 case 'B':
1208 if(!MSVCRT_CHECK_PMT(mstm->tm_mon>=0 && mstm->tm_mon<=11))
1209 goto einval_error;
1210 if(!strftime_str(str, &ret, max, STRFTIME_TD(time_data, mon)[mstm->tm_mon]))
1211 return 0;
1212 break;
1213#if _MSVCR_VER>=140
1214 case 'C':
1215 if(!MSVCRT_CHECK_PMT(year>=0 && year<=9999))
1216 goto einval_error;
1217 if(!strftime_int(str, &ret, max, year/100, alternate ? 0 : 2, 0, 99))
1218 return 0;
1219 break;
1220#endif
1221 case 'd':
1222 if(!strftime_int(str, &ret, max, mstm->tm_mday, alternate ? 0 : 2, 1, 31))
1223 return 0;
1224 break;
1225#if _MSVCR_VER>=140
1226 case 'D':
1227 if(!MSVCRT_CHECK_PMT(year>=0 && year<=9999))
1228 goto einval_error;
1229 if(!strftime_int(str, &ret, max, mstm->tm_mon+1, alternate ? 0 : 2, 1, 12))
1230 return 0;
1231 if(ret < max)
1232 str[ret++] = '/';
1233 if(!strftime_int(str, &ret, max, mstm->tm_mday, alternate ? 0 : 2, 1, 31))
1234 return 0;
1235 if(ret < max)
1236 str[ret++] = '/';
1237 if(!strftime_int(str, &ret, max, year%100, alternate ? 0 : 2, 0, 99))
1238 return 0;
1239 break;
1240 case 'e':
1241 if(!strftime_int(str, &ret, max, mstm->tm_mday, alternate ? 0 : 2, 1, 31))
1242 return 0;
1243 if(!alternate && str[ret-2] == '0')
1244 str[ret-2] = ' ';
1245 break;
1246 case 'F':
1247 if(!strftime_int(str, &ret, max, year, alternate ? 0 : 4, 0, 9999))
1248 return 0;
1249 if(ret < max)
1250 str[ret++] = '-';
1251 if(!strftime_int(str, &ret, max, mstm->tm_mon+1, alternate ? 0 : 2, 1, 12))
1252 return 0;
1253 if(ret < max)
1254 str[ret++] = '-';
1255 if(!strftime_int(str, &ret, max, mstm->tm_mday, alternate ? 0 : 2, 1, 31))
1256 return 0;
1257 break;
1258 case 'g':
1259 case 'G':
1260 if(!MSVCRT_CHECK_PMT(year>=0 && year<=9999))
1261 goto einval_error;
1262 /* fall through */
1263 case 'V':
1264 {
1265 int iso_year = year;
1266 int iso_days = mstm->tm_yday - (mstm->tm_wday ? mstm->tm_wday : 7) + 4;
1267 if (iso_days < 0)
1268 iso_days += 365 + IsLeapYear(--iso_year);
1269 else if(iso_days >= 365 + IsLeapYear(iso_year))
1270 iso_days -= 365 + IsLeapYear(iso_year++);
1271
1272 if(*format == 'G') {
1273 if(!strftime_int(str, &ret, max, iso_year, 4, 0, 9999))
1274 return 0;
1275 } else if(*format == 'g') {
1276 if(!strftime_int(str, &ret, max, iso_year%100, 2, 0, 99))
1277 return 0;
1278 } else {
1279 if(!strftime_int(str, &ret, max, iso_days/7 + 1, alternate ? 0 : 2, 0, 53))
1280 return 0;
1281 }
1282 break;
1283 }
1284#endif
1285 case 'H':
1286 if(!strftime_int(str, &ret, max, mstm->tm_hour, alternate ? 0 : 2, 0, 23))
1287 return 0;
1288 break;
1289 case 'I':
1290 if(!MSVCRT_CHECK_PMT(mstm->tm_hour>=0 && mstm->tm_hour<=23))
1291 goto einval_error;
1292 if(!strftime_int(str, &ret, max, (mstm->tm_hour + 11) % 12 + 1,
1293 alternate ? 0 : 2, 1, 12))
1294 return 0;
1295 break;
1296 case 'j':
1297 if(!strftime_int(str, &ret, max, mstm->tm_yday+1, alternate ? 0 : 3, 1, 366))
1298 return 0;
1299 break;
1300 case 'm':
1301 if(!strftime_int(str, &ret, max, mstm->tm_mon+1, alternate ? 0 : 2, 1, 12))
1302 return 0;
1303 break;
1304 case 'M':
1305 if(!strftime_int(str, &ret, max, mstm->tm_min, alternate ? 0 : 2, 0, 59))
1306 return 0;
1307 break;
1308#if _MSVCR_VER>=140
1309 case 'n':
1310 str[ret++] = '\n';
1311 break;
1312#endif
1313 case 'p':
1314 if(!MSVCRT_CHECK_PMT(mstm->tm_hour>=0 && mstm->tm_hour<=23))
1315 goto einval_error;
1316 if(!strftime_str(str, &ret, max, mstm->tm_hour<12 ?
1317 STRFTIME_TD(time_data, am) : STRFTIME_TD(time_data, pm)))
1318 return 0;
1319 break;
1320#if _MSVCR_VER>=140
1321 case 'r':
1322 if(time_data == &cloc_time_data)
1323 {
1324 if(!MSVCRT_CHECK_PMT(mstm->tm_hour>=0 && mstm->tm_hour<=23))
1325 goto einval_error;
1326 if(!strftime_int(str, &ret, max, (mstm->tm_hour + 11) % 12 + 1,
1327 alternate ? 0 : 2, 1, 12))
1328 return 0;
1329 if(ret < max)
1330 str[ret++] = ':';
1331 if(!strftime_int(str, &ret, max, mstm->tm_min, alternate ? 0 : 2, 0, 59))
1332 return 0;
1333 if(ret < max)
1334 str[ret++] = ':';
1335 if(!strftime_int(str, &ret, max, mstm->tm_sec, alternate ? 0 : 2, 0, MAX_SECONDS))
1336 return 0;
1337 if(ret < max)
1338 str[ret++] = ' ';
1339 if(!strftime_str(str, &ret, max, mstm->tm_hour<12 ?
1340 STRFTIME_TD(time_data, am) : STRFTIME_TD(time_data, pm)))
1341 return 0;
1342 }
1343 else
1344 {
1345 if(!strftime_format(str, &ret, max, mstm, time_data, STRFTIME_TD(time_data, time)))
1346 return 0;
1347 }
1348 break;
1349 case 'R':
1350 if(!strftime_int(str, &ret, max, mstm->tm_hour, alternate ? 0 : 2, 0, 23))
1351 return 0;
1352 if(ret < max)
1353 str[ret++] = ':';
1354 if(!strftime_int(str, &ret, max, mstm->tm_min, alternate ? 0 : 2, 0, 59))
1355 return 0;
1356 break;
1357#endif
1358 case 'S':
1359 if(!strftime_int(str, &ret, max, mstm->tm_sec, alternate ? 0 : 2, 0, MAX_SECONDS))
1360 return 0;
1361 break;
1362#if _MSVCR_VER>=140
1363 case 't':
1364 str[ret++] = '\t';
1365 break;
1366 case 'T':
1367 if(!strftime_int(str, &ret, max, mstm->tm_hour, alternate ? 0 : 2, 0, 23))
1368 return 0;
1369 if(ret < max)
1370 str[ret++] = ':';
1371 if(!strftime_int(str, &ret, max, mstm->tm_min, alternate ? 0 : 2, 0, 59))
1372 return 0;
1373 if(ret < max)
1374 str[ret++] = ':';
1375 if(!strftime_int(str, &ret, max, mstm->tm_sec, alternate ? 0 : 2, 0, MAX_SECONDS))
1376 return 0;
1377 break;
1378 case 'u':
1379 if(!MSVCRT_CHECK_PMT(mstm->tm_wday>=0 && mstm->tm_wday<=6))
1380 goto einval_error;
1381 tmp = mstm->tm_wday ? mstm->tm_wday : 7;
1382 if(!strftime_int(str, &ret, max, tmp, 0, 1, 7))
1383 return 0;
1384 break;
1385#endif
1386 case 'w':
1387 if(!strftime_int(str, &ret, max, mstm->tm_wday, 0, 0, 6))
1388 return 0;
1389 break;
1390 case 'y':
1391#if _MSVCR_VER>=140
1392 if(!MSVCRT_CHECK_PMT(year>=0 && year<=9999))
1393#else
1394 if(!MSVCRT_CHECK_PMT(year>=1900))
1395#endif
1396 goto einval_error;
1397 if(!strftime_int(str, &ret, max, year%100, alternate ? 0 : 2, 0, 99))
1398 return 0;
1399 break;
1400 case 'Y':
1401 if(!strftime_int(str, &ret, max, year, alternate ? 0 : 4, 0, 9999))
1402 return 0;
1403 break;
1404 case 'z':
1405#if _MSVCR_VER>=140
1406 _tzset();
1407 if(!strftime_tzdiff(str, &ret, max, mstm->tm_isdst))
1408 return 0;
1409 break;
1410#endif
1411 case 'Z':
1412 _tzset();
1413#if _MSVCR_VER <= 90
1414 if(_get_tzname(&tmp, str+ret, max-ret, mstm->tm_isdst ? 1 : 0))
1415 return 0;
1416#else
1417 if(_mbstowcs_s_l(&tmp, str+ret, max-ret,
1418 mstm->tm_isdst ? tzname_dst : tzname_std,
1419 _TRUNCATE, loc) == STRUNCATE)
1420 ret = max;
1421#endif
1422 ret += tmp-1;
1423 break;
1424 case 'U':
1425 case 'W':
1426 if(!MSVCRT_CHECK_PMT(mstm->tm_wday>=0 && mstm->tm_wday<=6))
1427 goto einval_error;
1428 if(!MSVCRT_CHECK_PMT(mstm->tm_yday>=0 && mstm->tm_yday<=365))
1429 goto einval_error;
1430 if(*format == 'U')
1431 tmp = mstm->tm_wday;
1432 else if(!mstm->tm_wday)
1433 tmp = 6;
1434 else
1435 tmp = mstm->tm_wday-1;
1436
1437 tmp = mstm->tm_yday/7 + (tmp<=mstm->tm_yday%7);
1438 if(!strftime_int(str, &ret, max, tmp, alternate ? 0 : 2, 0, 53))
1439 return 0;
1440 break;
1441 case '%':
1442 str[ret++] = '%';
1443 break;
1444 default:
1445 WARN("unknown format %c\n", *format);
1446 MSVCRT_INVALID_PMT("unknown format", EINVAL);
1447 goto einval_error;
1448 }
1449 }
1450
1451 if(ret == max) {
1452 if(max)
1453 *str = 0;
1454 *_errno() = ERANGE;
1455 return 0;
1456 }
1457
1458 str[ret] = 0;
1459 return ret;
1460
1461einval_error:
1462 *str = 0;
1463 return 0;
1464}
1465
1466static size_t strftime_helper(char *str, size_t max, const char *format,
1467 const struct tm *mstm, __lc_time_data *time_data, _locale_t loc)
1468{
1469#if _MSVCR_VER <= 90
1470 TRACE("(%p %Iu %s %p %p %p)\n", str, max, format, mstm, time_data, loc);
1471 return strftime_impl(str, max, format, mstm, time_data, loc);
1472#else
1473 wchar_t *s, *fmt;
1474 size_t len;
1475 int cp;
1476
1477 TRACE("(%p %Iu %s %p %p %p)\n", str, max, format, mstm, time_data, loc);
1478
1479 if (!MSVCRT_CHECK_PMT(str != NULL)) return 0;
1480 if (!MSVCRT_CHECK_PMT(max != 0)) return 0;
1481 *str = 0;
1482 if (!MSVCRT_CHECK_PMT(format != NULL)) return 0;
1483
1484 cp = (loc ? loc->locinfo : get_locinfo())->lc_id[LC_TIME].wCodePage;
1485
1486 len = MultiByteToWideChar( cp, 0, format, -1, NULL, 0 );
1487 if (!len)
1488 {
1489 *_errno() = EILSEQ;
1490 return 0;
1491 }
1492 fmt = malloc( len*sizeof(wchar_t) );
1493 if (!fmt) return 0;
1494 MultiByteToWideChar( cp, 0, format, -1, fmt, len );
1495
1496 if ((s = malloc( max*sizeof(wchar_t) )))
1497 {
1498 len = strftime_impl( s, max, fmt, mstm, time_data, loc );
1499 if (len)
1500 {
1501 len = WideCharToMultiByte( cp, 0, s, -1, str, max, NULL, NULL );
1502 if (len) len--;
1503 else *_errno() = EILSEQ;
1504 }
1505 free( s );
1506 }
1507 else len = 0;
1508
1509 free( fmt );
1510 return len;
1511#endif
1512}
1513
1514#if _MSVCR_VER >= 80
1515/********************************************************************
1516 * _strftime_l (MSVCR80.@)
1517 */
1518size_t CDECL _strftime_l( char *str, size_t max, const char *format,
1519 const struct tm *mstm, _locale_t loc )
1520{
1521 return strftime_helper(str, max, format, mstm, NULL, loc);
1522}
1523#endif
1524
1525/*********************************************************************
1526 * _Strftime (MSVCRT.@)
1527 */
1528size_t CDECL _Strftime(char *str, size_t max, const char *format,
1529 const struct tm *mstm, void *time_data)
1530{
1531 return strftime_helper(str, max, format, mstm, time_data, NULL);
1532}
1533
1534/*********************************************************************
1535 * strftime (MSVCRT.@)
1536 */
1537size_t CDECL strftime( char *str, size_t max, const char *format,
1538 const struct tm *mstm )
1539{
1540 return strftime_helper(str, max, format, mstm, NULL, NULL);
1541}
1542
1543static size_t wcsftime_helper( wchar_t *str, size_t max,
1544 const wchar_t *format, const struct tm *mstm,
1545 __lc_time_data *time_data, _locale_t loc )
1546{
1547#if _MSVCR_VER <= 90
1548 char *s, *fmt;
1549 size_t len;
1550
1551 TRACE("%p %Iu %s %p %p %p\n", str, max, debugstr_w(format), mstm, time_data, loc);
1552
1553 len = _wcstombs_l( NULL, format, 0, loc ) + 1;
1554 if (!(fmt = malloc( len ))) return 0;
1555 _wcstombs_l(fmt, format, len, loc);
1556
1557 if ((s = malloc( max*4 )))
1558 {
1559 if (!strftime_impl( s, max*4, fmt, mstm, time_data, loc )) s[0] = 0;
1560 len = _mbstowcs_l( str, s, max, loc );
1561 free( s );
1562 }
1563 else len = 0;
1564
1565 free( fmt );
1566 return len;
1567#else
1568 TRACE("%p %Iu %s %p %p %p\n", str, max, debugstr_w(format), mstm, time_data, loc);
1569 return strftime_impl(str, max, format, mstm, time_data, loc);
1570#endif
1571}
1572
1573/*********************************************************************
1574 * _wcsftime_l (MSVCRT.@)
1575 */
1576size_t CDECL _wcsftime_l( wchar_t *str, size_t max,
1577 const wchar_t *format, const struct tm *mstm, _locale_t loc )
1578{
1579 return wcsftime_helper(str, max, format, mstm, NULL, loc);
1580}
1581
1582/*********************************************************************
1583 * wcsftime (MSVCRT.@)
1584 */
1585size_t CDECL wcsftime( wchar_t *str, size_t max,
1586 const wchar_t *format, const struct tm *mstm )
1587{
1588 return wcsftime_helper(str, max, format, mstm, NULL, NULL);
1589}
1590
1591#if _MSVCR_VER >= 110
1592/*********************************************************************
1593 * _Wcsftime (MSVCR110.@)
1594 */
1595size_t CDECL _Wcsftime(wchar_t *str, size_t max,
1596 const wchar_t *format, const struct tm *mstm,
1597 __lc_time_data *time_data)
1598{
1599 return wcsftime_helper(str, max, format, mstm, time_data, NULL);
1600}
1601#endif
1602
1603static char* asctime_buf(char *buf, const struct tm *mstm)
1604{
1605 static const char wday[7][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
1606 static const char month[12][4] = {"Jan", "Feb", "Mar", "Apr", "May",
1607 "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
1608
1609 if (!mstm || mstm->tm_sec<0 || mstm->tm_sec>59
1610 || mstm->tm_min<0 || mstm->tm_min>59
1611 || mstm->tm_hour<0 || mstm->tm_hour>23
1612 || mstm->tm_mon<0 || mstm->tm_mon>11
1613 || mstm->tm_wday<0 || mstm->tm_wday>6
1614 || mstm->tm_year<0 || mstm->tm_mday<0
1615 || mstm->tm_mday>MonthLengths[IsLeapYear(1900+mstm->tm_year)][mstm->tm_mon]) {
1616 *_errno() = EINVAL;
1617 return NULL;
1618 }
1619
1620#if _MSVCR_VER>=140
1621 /* C89 (4.12.3.1) uses space-padding for day of month. */
1622 _snprintf(buf, 26, "%s %s %2d %02d:%02d:%02d %c%03d\n", wday[mstm->tm_wday],
1623 month[mstm->tm_mon], mstm->tm_mday, mstm->tm_hour, mstm->tm_min,
1624 mstm->tm_sec, '1'+(mstm->tm_year+900)/1000, (900+mstm->tm_year)%1000);
1625#else
1626 _snprintf(buf, 26, "%s %s %02d %02d:%02d:%02d %c%03d\n", wday[mstm->tm_wday],
1627 month[mstm->tm_mon], mstm->tm_mday, mstm->tm_hour, mstm->tm_min,
1628 mstm->tm_sec, '1'+(mstm->tm_year+900)/1000, (900+mstm->tm_year)%1000);
1629#endif
1630 return buf;
1631}
1632
1633/*********************************************************************
1634 * asctime (MSVCRT.@)
1635 */
1636char * CDECL asctime(const struct tm *mstm)
1637{
1639
1640 /* asctime returns date in format that always has exactly 26 characters */
1641 if (!data->asctime_buffer) {
1642 data->asctime_buffer = malloc(26);
1643 if (!data->asctime_buffer) {
1644 *_errno() = ENOMEM;
1645 return NULL;
1646 }
1647 }
1648
1649 return asctime_buf(data->asctime_buffer, mstm);
1650}
1651
1652/*********************************************************************
1653 * asctime_s (MSVCRT.@)
1654 */
1655int CDECL asctime_s(char* time, size_t size, const struct tm *mstm)
1656{
1657 if (!MSVCRT_CHECK_PMT(time != NULL)) return EINVAL;
1658 if (size) time[0] = 0;
1659 if (!MSVCRT_CHECK_PMT(size >= 26)) return EINVAL;
1660 if (!MSVCRT_CHECK_PMT(mstm != NULL)) return EINVAL;
1661 if (!MSVCRT_CHECK_PMT(mstm->tm_sec >= 0 && mstm->tm_sec < 60)) return EINVAL;
1662 if (!MSVCRT_CHECK_PMT(mstm->tm_min >= 0 && mstm->tm_min < 60)) return EINVAL;
1663 if (!MSVCRT_CHECK_PMT(mstm->tm_hour >= 0 && mstm->tm_hour < 24)) return EINVAL;
1664 if (!MSVCRT_CHECK_PMT(mstm->tm_mon >= 0 && mstm->tm_mon < 12)) return EINVAL;
1665 if (!MSVCRT_CHECK_PMT(mstm->tm_wday >= 0 && mstm->tm_wday < 7)) return EINVAL;
1666 if (!MSVCRT_CHECK_PMT(mstm->tm_year >= 0)) return EINVAL;
1667 if (!MSVCRT_CHECK_PMT(mstm->tm_mday >= 0)) return EINVAL;
1668 if (!MSVCRT_CHECK_PMT(mstm->tm_mday <= MonthLengths[IsLeapYear(1900+mstm->tm_year)][mstm->tm_mon])) return EINVAL;
1669
1670 asctime_buf(time, mstm);
1671 return 0;
1672}
1673
1674/*********************************************************************
1675 * _wasctime (MSVCRT.@)
1676 */
1677wchar_t * CDECL _wasctime(const struct tm *mstm)
1678{
1680 char buffer[26];
1681
1682 if(!data->wasctime_buffer) {
1683 data->wasctime_buffer = malloc(26*sizeof(wchar_t));
1684 if(!data->wasctime_buffer) {
1685 *_errno() = ENOMEM;
1686 return NULL;
1687 }
1688 }
1689
1690 if(!asctime_buf(buffer, mstm))
1691 return NULL;
1692
1693 MultiByteToWideChar(CP_ACP, 0, buffer, -1, data->wasctime_buffer, 26);
1694 return data->wasctime_buffer;
1695}
1696
1697/*********************************************************************
1698 * _wasctime_s (MSVCRT.@)
1699 */
1700int CDECL _wasctime_s(wchar_t* time, size_t size, const struct tm *mstm)
1701{
1702 char buffer[26];
1703 int ret;
1704
1705 if (!MSVCRT_CHECK_PMT(time != NULL)) return EINVAL;
1706 if (size) time[0] = 0;
1707 if (!MSVCRT_CHECK_PMT(size >= 26)) return EINVAL;
1708 if (!MSVCRT_CHECK_PMT(mstm != NULL)) return EINVAL;
1709
1710 ret = asctime_s(buffer, sizeof(buffer), mstm);
1711 if(ret)
1712 return ret;
1714 return 0;
1715}
1716
1717/*********************************************************************
1718 * _ctime64 (MSVCRT.@)
1719 */
1721{
1722 struct tm *t;
1723 t = _localtime64( time );
1724 if (!t) return NULL;
1725 return asctime( t );
1726}
1727
1728/*********************************************************************
1729 * _ctime64_s (MSVCRT.@)
1730 */
1732{
1733 struct tm t;
1734 int ret;
1735
1736 if (!MSVCRT_CHECK_PMT( res != NULL )) return EINVAL;
1737 if (!MSVCRT_CHECK_PMT( len >= 26 )) return EINVAL;
1738 res[0] = '\0';
1739 if (!MSVCRT_CHECK_PMT( time != NULL )) return EINVAL;
1740 if (!MSVCRT_CHECK_PMT( *time > 0 )) return EINVAL;
1741
1742 ret = _localtime64_s( &t, time );
1743 if (ret)
1744 return ret;
1745 return asctime_s( res, len, &t );
1746}
1747
1748/*********************************************************************
1749 * _ctime32 (MSVCRT.@)
1750 */
1752{
1753 struct tm *t;
1754 t = _localtime32( time );
1755 if (!t) return NULL;
1756 return asctime( t );
1757}
1758
1759/*********************************************************************
1760 * _ctime32_s (MSVCRT.@)
1761 */
1763{
1764 struct tm t;
1765 int ret;
1766
1767 if (!MSVCRT_CHECK_PMT( res != NULL )) return EINVAL;
1768 if (!MSVCRT_CHECK_PMT( len >= 26 )) return EINVAL;
1769 res[0] = '\0';
1770 if (!MSVCRT_CHECK_PMT( time != NULL )) return EINVAL;
1771 if (!MSVCRT_CHECK_PMT( *time > 0 )) return EINVAL;
1772
1773 ret = _localtime32_s( &t, time );
1774 if (ret)
1775 return ret;
1776 return asctime_s( res, len, &t );
1777}
1778
1779/*********************************************************************
1780 * _wctime64 (MSVCRT.@)
1781 */
1783{
1784 return _wasctime( _localtime64(time) );
1785}
1786
1787/*********************************************************************
1788 * _wctime32 (MSVCRT.@)
1789 */
1791{
1792 return _wasctime( _localtime32(time) );
1793}
1794
1795/*********************************************************************
1796 * _wctime64_s (MSVCRT.@)
1797 */
1798int CDECL _wctime64_s(wchar_t *buf,
1799 size_t size, const __time64_t *time)
1800{
1801 struct tm tm;
1802 int ret;
1803
1804 if(!MSVCRT_CHECK_PMT(buf != NULL)) return EINVAL;
1805 if(!MSVCRT_CHECK_PMT(size != 0)) return EINVAL;
1806 buf[0] = 0;
1807 if(!MSVCRT_CHECK_PMT(time != NULL)) return EINVAL;
1808 if(!MSVCRT_CHECK_PMT(*time >= 0)) return EINVAL;
1809 if(!MSVCRT_CHECK_PMT(*time <= _MAX__TIME64_T)) return EINVAL;
1810
1812 if(ret != 0)
1813 return ret;
1814
1815 return _wasctime_s(buf, size, &tm);
1816}
1817
1818/*********************************************************************
1819 * _wctime32_s (MSVCRT.@)
1820 */
1821int CDECL _wctime32_s(wchar_t *buf, size_t size,
1822 const __time32_t *time)
1823{
1824 struct tm tm;
1825 int ret;
1826
1827 if(!MSVCRT_CHECK_PMT(buf != NULL)) return EINVAL;
1828 if(!MSVCRT_CHECK_PMT(size != 0)) return EINVAL;
1829 buf[0] = 0;
1830 if(!MSVCRT_CHECK_PMT(time != NULL)) return EINVAL;
1831 if(!MSVCRT_CHECK_PMT(*time >= 0)) return EINVAL;
1832
1834 if(ret != 0)
1835 return ret;
1836
1837 return _wasctime_s(buf, size, &tm);
1838}
1839
1840#if _MSVCR_VER >= 80
1841
1842/*********************************************************************
1843 * _get_timezone (MSVCR80.@)
1844 */
1846{
1847 if(!MSVCRT_CHECK_PMT(timezone != NULL)) return EINVAL;
1848
1850 return 0;
1851}
1852
1853/*********************************************************************
1854 * _get_daylight (MSVCR80.@)
1855 */
1856int CDECL _get_daylight(int *hours)
1857{
1858 if(!MSVCRT_CHECK_PMT(hours != NULL)) return EINVAL;
1859
1860 *hours = MSVCRT___daylight;
1861 return 0;
1862}
1863
1864#endif /* _MSVCR_VER >= 80 */
1865
1866#if _MSVCR_VER >= 140
1867
1868#define TIME_UTC 1
1869
1870/*********************************************************************
1871 * _timespec64_get (UCRTBASE.@)
1872 */
1873int CDECL _timespec64_get(struct _timespec64 *ts, int base)
1874{
1876 FILETIME ft;
1877
1878 if(!MSVCRT_CHECK_PMT(ts != NULL)) return 0;
1879 if(base != TIME_UTC) return 0;
1880
1882 time = ((ULONGLONG)ft.dwHighDateTime << 32) | ft.dwLowDateTime;
1883
1885 ts->tv_nsec = time % TICKSPERSEC * 100;
1886 return base;
1887}
1888
1889/*********************************************************************
1890 * _timespec32_get (UCRTBASE.@)
1891 */
1892int CDECL _timespec32_get(struct _timespec32 *ts, int base)
1893{
1894 struct _timespec64 ts64;
1895
1896 if(!MSVCRT_CHECK_PMT(ts != NULL)) return 0;
1897 if(base != TIME_UTC) return 0;
1898
1899 if(_timespec64_get(&ts64, base) != base)
1900 return 0;
1901 if(ts64.tv_sec != (__time32_t)ts64.tv_sec)
1902 return 0;
1903
1904 ts->tv_sec = ts64.tv_sec;
1905 ts->tv_nsec = ts64.tv_nsec;
1906 return base;
1907}
1908#endif /* _MSVCR_VER >= 140 */
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define WARN(fmt,...)
Definition: precomp.h:61
r l[0]
Definition: byte_order.h:168
#define _isleadbyte_l(_C, _L)
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CDECL
Definition: compat.h:29
#define CP_ACP
Definition: compat.h:109
#define lstrcpynA
Definition: compat.h:751
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:158
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
VOID WINAPI GetSystemTimePreciseAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:148
BOOL WINAPI SystemTimeToTzSpecificLocalTime(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation, CONST SYSTEMTIME *lpUniversalTime, LPSYSTEMTIME lpLocalTime)
Definition: timezone.c:377
DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
Definition: timezone.c:262
char *CDECL getenv(const char *name)
Definition: environ.c:227
int *CDECL _errno(void)
Definition: errno.c:215
__msvcrt_long __time32_t
Definition: corecrt.h:209
int errno_t
Definition: corecrt.h:249
long __msvcrt_long
Definition: corecrt.h:167
_ACRTIMP int __cdecl _snwprintf(wchar_t *, size_t, const wchar_t *,...)
Definition: wcs.c:1493
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2802
#define EINVAL
Definition: errno.h:44
#define STRUNCATE
Definition: errno.h:64
#define ENOMEM
Definition: errno.h:35
#define ERANGE
Definition: errno.h:55
#define EILSEQ
Definition: errno.h:62
#define SIZE_MAX
Definition: limits.h:49
#define LC_TIME
Definition: locale.h:30
_ACRTIMP __msvcrt_long __cdecl strtol(const char *, char **, int)
Definition: string.c:1833
#define _TRUNCATE
Definition: stdlib.h:45
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
_ACRTIMP size_t __cdecl _strftime_l(char *, size_t, const char *, const struct tm *, _locale_t)
#define CLOCKS_PER_SEC
Definition: time.h:33
__msvcrt_long clock_t
Definition: time.h:28
__lc_time_data cloc_time_data
Definition: locale.c:60
void CDECL _lock(int locknum)
Definition: lock.c:85
void CDECL _unlock(int locknum)
Definition: lock.c:114
thread_data_t *CDECL msvcrt_get_thread_data(void)
Definition: thread.c:45
#define _MAX__TIME64_T
Definition: msvcrt.h:339
#define MSVCRT_INVALID_PMT(x, err)
Definition: msvcrt.h:376
#define MSVCRT_CHECK_PMT(x)
Definition: msvcrt.h:378
#define _TIME_LOCK
Definition: mtdll.h:35
int CDECL _localtime64_s(struct tm *res, const __time64_t *secs)
Definition: time.c:367
int CDECL _wctime64_s(wchar_t *buf, size_t size, const __time64_t *time)
Definition: time.c:1798
int CDECL _wasctime_s(wchar_t *time, size_t size, const struct tm *mstm)
Definition: time.c:1700
#define TICKSPERSEC
Definition: time.c:236
#define SECSPERDAY
Definition: time.c:233
__msvcrt_long MSVCRT___timezone
Definition: time.c:106
int CDECL _localtime32_s(struct tm *time, const __time32_t *secs)
Definition: time.c:444
#define strftime_str(a, b, c, d)
Definition: time.c:896
static BOOL strftime_int(STRFTIME_CHAR *str, size_t *pos, size_t max, int src, int prec, int l, int h)
Definition: time.c:916
__time64_t CDECL _mktime64(struct tm *mstm)
Definition: time.c:331
char *CDECL asctime(const struct tm *mstm)
Definition: time.c:1636
__time64_t CDECL _time64(__time64_t *buf)
Definition: time.c:780
void CDECL _ftime32(struct __timeb32 *buf)
Definition: time.c:756
struct tm *CDECL _localtime64(const __time64_t *secs)
Definition: time.c:415
#define TICKS_1601_TO_1970
Definition: time.c:238
#define STRFTIME_TD(td, name)
Definition: time.c:890
char *CDECL _ctime32(const __time32_t *time)
Definition: time.c:1751
#define SECS_1601_TO_1970
Definition: time.c:235
static size_t wcsftime_helper(wchar_t *str, size_t max, const wchar_t *format, const struct tm *mstm, __lc_time_data *time_data, _locale_t loc)
Definition: time.c:1543
#define MAX_GMTIME64_TIME
Definition: time.c:71
errno_t CDECL _ctime64_s(char *res, size_t len, const __time64_t *time)
Definition: time.c:1731
struct tm *CDECL _gmtime32(const __time32_t *secs)
Definition: time.c:538
int CDECL _ftime32_s(struct __timeb32 *buf)
Definition: time.c:770
char *CDECL _ctime64(const __time64_t *time)
Definition: time.c:1720
static BOOL strftime_nstr(STRFTIME_CHAR *str, size_t *pos, size_t max, const STRFTIME_CHAR *src, size_t len)
Definition: time.c:897
__time32_t CDECL _mktime32(struct tm *mstm)
Definition: time.c:339
int CDECL _strtime_s(char *time, size_t size)
Definition: time.c:645
wchar_t *CDECL _wctime32(const __time32_t *time)
Definition: time.c:1790
struct tm *CDECL _localtime32(const __time32_t *secs)
Definition: time.c:430
int CDECL _wctime32_s(wchar_t *buf, size_t size, const __time32_t *time)
Definition: time.c:1821
int CDECL _strdate_s(char *date, size_t size)
Definition: time.c:572
char **CDECL __p__tzname(void)
Definition: time.c:883
static __time64_t mktime_helper(struct tm *mstm, BOOL local)
Definition: time.c:240
static void write_invalid_msvcrt_tm(struct tm *tm)
Definition: time.c:85
__time32_t CDECL _time32(__time32_t *buf)
Definition: time.c:794
__msvcrt_long *CDECL __p__dstbias(void)
Definition: time.c:816
__msvcrt_long *CDECL __p__timezone(void)
Definition: time.c:836
int MSVCRT___daylight
Definition: time.c:101
clock_t CDECL clock(void)
Definition: time.c:698
static char * asctime_buf(char *buf, const struct tm *mstm)
Definition: time.c:1603
__time32_t CDECL _mkgmtime32(struct tm *time)
Definition: time.c:358
size_t CDECL strftime(char *str, size_t max, const char *format, const struct tm *mstm)
Definition: time.c:1537
errno_t CDECL _ctime32_s(char *res, size_t len, const __time32_t *time)
Definition: time.c:1762
size_t CDECL _wcsftime_l(wchar_t *str, size_t max, const wchar_t *format, const struct tm *mstm, _locale_t loc)
Definition: time.c:1576
size_t CDECL wcsftime(wchar_t *str, size_t max, const wchar_t *format, const struct tm *mstm)
Definition: time.c:1585
void CDECL _tzset(void)
Definition: time.c:127
static size_t strftime_impl(STRFTIME_CHAR *str, size_t max, const STRFTIME_CHAR *format, const struct tm *mstm, __lc_time_data *time_data, _locale_t loc)
Definition: time.c:1116
int CDECL asctime_s(char *time, size_t size, const struct tm *mstm)
Definition: time.c:1655
static size_t strftime_helper(char *str, size_t max, const char *format, const struct tm *mstm, __lc_time_data *time_data, _locale_t loc)
Definition: time.c:1466
wchar_t *CDECL _wctime64(const __time64_t *time)
Definition: time.c:1782
static void _tzset_init(void)
Definition: time.c:182
int CDECL _ftime64_s(struct __timeb64 *buf)
Definition: time.c:746
void msvcrt_init_clock(void)
Definition: time.c:49
int CDECL _wstrtime_s(wchar_t *time, size_t size)
Definition: time.c:676
static char tzname_std[64]
Definition: time.c:119
int CDECL _wstrdate_s(wchar_t *date, size_t size)
Definition: time.c:603
__msvcrt_long MSVCRT__dstbias
Definition: time.c:111
__time64_t CDECL _mkgmtime64(struct tm *time)
Definition: time.c:350
wchar_t *CDECL _wasctime(const struct tm *mstm)
Definition: time.c:1677
static char tzname_dst[64]
Definition: time.c:120
int CDECL _get_tzname(size_t *ret, char *buf, size_t bufsize, int index)
Definition: time.c:844
static const int MonthLengths[2][12]
Definition: time.c:57
static TIME_ZONE_INFORMATION tzi
Definition: time.c:123
double CDECL _difftime32(__time32_t time1, __time32_t time2)
Definition: time.c:717
int *CDECL __p__daylight(void)
Definition: time.c:808
char * MSVCRT__tzname[2]
Definition: time.c:121
static LONGLONG init_time
Definition: time.c:47
static BOOL is_dst(const SYSTEMTIME *st)
Definition: time.c:196
int CDECL _gmtime64_s(struct tm *res, const __time64_t *secs)
Definition: time.c:464
#define TICKSPERMSEC
Definition: time.c:237
struct tm *CDECL _gmtime64(const __time64_t *secs)
Definition: time.c:509
#define STRFTIME_CHAR
Definition: time.c:889
size_t CDECL _Strftime(char *str, size_t max, const char *format, const struct tm *mstm, void *time_data)
Definition: time.c:1528
void CDECL _ftime64(struct __timeb64 *buf)
Definition: time.c:725
static BOOL strftime_format(STRFTIME_CHAR *str, size_t *pos, size_t max, const struct tm *mstm, __lc_time_data *time_data, const STRFTIME_CHAR *format)
Definition: time.c:941
int CDECL _gmtime32_s(struct tm *res, const __time32_t *secs)
Definition: time.c:524
static const int MAX_SECONDS
Definition: time.c:66
double CDECL _difftime64(__time64_t time1, __time64_t time2)
Definition: time.c:709
static const WCHAR month[12][4]
Definition: session.c:2150
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
#define local
Definition: zutil.h:30
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble GLdouble t
Definition: gl.h:2047
GLbyte GLbyte tz
Definition: glext.h:8756
GLuint res
Definition: glext.h:9613
GLenum src
Definition: glext.h:6340
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
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
GLenum GLsizei len
Definition: glext.h:6722
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
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
#define debugstr_w
Definition: kernel32.h:32
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1089
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:989
static LPMONITOREX pm
Definition: localmon.c:45
POINT cp
Definition: magnifier.c:59
#define sign(x)
Definition: mapdesc.cc:613
__u16 date
Definition: mkdosfs.c:8
__u16 time
Definition: mkdosfs.c:8
#define error(str)
Definition: mkdosfs.c:1605
static const WCHAR tb[]
Definition: suminfo.c:285
unsigned int UINT
Definition: ndis.h:50
#define TIME_ZONE_ID_DAYLIGHT
Definition: rtltypes.h:254
#define LOCALE_NEUTRAL
NTSTATUS NTAPI NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
Definition: time.c:569
long LONG
Definition: pedump.c:60
const WCHAR * str
_CRTIMP errno_t __cdecl _get_daylight(_Out_ int *_Daylight)
_CRTIMP errno_t __cdecl _get_dstbias(_Out_ long *_Daylight_savings_bias)
_CRTIMP errno_t __cdecl _get_timezone(_Out_ long *_Timezone)
__int64 __time64_t
Definition: corecrt.h:619
_wstrtime
_wstrdate
_wcstombs_l
Definition: stdlib.h:1039
_mbstowcs_s_l
Definition: stdlib.h:951
_mbstowcs_l
Definition: stdlib.h:951
strcpy
Definition: string.h:131
_strdate
Definition: time.h:297
#define TIME_UTC
Definition: time.h:57
_strtime
Definition: time.h:313
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
WORD wSecond
Definition: minwinbase.h:262
WORD wMinute
Definition: minwinbase.h:261
WORD wDayOfWeek
Definition: minwinbase.h:258
SYSTEMTIME DaylightDate
Definition: winbase.h:936
WCHAR DaylightName[32]
Definition: winbase.h:935
WCHAR StandardName[32]
Definition: winbase.h:932
SYSTEMTIME StandardDate
Definition: winbase.h:933
short timezone
Definition: timeb.h:47
short dstflag
Definition: timeb.h:48
__time64_t time
Definition: timeb.h:45
unsigned short millitm
Definition: timeb.h:46
__time32_t tv_sec
Definition: time.h:42
__msvcrt_long tv_nsec
Definition: time.h:43
__time64_t tv_sec
Definition: time.h:48
__msvcrt_long tv_nsec
Definition: time.h:49
Definition: dsound.c:943
Definition: format.c:58
pthreadlocinfo locinfo
Definition: corecrt.h:260
struct __lc_time_data * lc_time_curr
Definition: corecrt.h:309
Definition: fake.h:14
int tm_mon
Definition: corecrt_wtime.h:16
int tm_year
Definition: corecrt_wtime.h:17
int tm_hour
Definition: corecrt_wtime.h:14
int tm_sec
Definition: corecrt_wtime.h:12
int tm_isdst
Definition: corecrt_wtime.h:20
int tm_yday
Definition: corecrt_wtime.h:19
int tm_mday
Definition: corecrt_wtime.h:15
int tm_min
Definition: corecrt_wtime.h:13
int tm_wday
Definition: corecrt_wtime.h:18
#define max(a, b)
Definition: svc.c:63
int __cdecl _timespec64_get(_timespec64 *const ts, int const base)
Definition: time.cpp:53
int __cdecl _timespec32_get(_timespec32 *const ts, int const base)
Definition: time.cpp:48
int64_t LONGLONG
Definition: typedefs.h:68
uint64_t ULONGLONG
Definition: typedefs.h:67
LONGLONG QuadPart
Definition: typedefs.h:114
#define IsLeapYear(y)
Definition: variant.c:1048
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
size_t __cdecl _Wcsftime(wchar_t *const buffer, size_t const max_size, wchar_t const *const format, tm const *const timeptr, void *const lc_time_arg)
Definition: wcsftime.cpp:1170
#define TIME_ZONE_ID_INVALID
Definition: winbase.h:310
#define get_locinfo()
Definition: winesup.h:25
static int init
Definition: wintirpc.c:33
#define _snprintf
Definition: xmlstorage.h:200