2 * Win32 kernel time functions
4 * Copyright 1995 Martin von Loewis and Cameron Heide
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #ifdef HAVE_SYS_TIME_H
29 # include <sys/time.h>
31 #ifdef HAVE_SYS_TIMES_H
32 # include <sys/times.h>
35 #define NONAMELESSUNION
36 #define NONAMELESSSTRUCT
42 #include "kernel_private.h"
43 #include "wine/unicode.h"
44 #include "wine/debug.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(win32
);
48 /* maximum time adjustment in seconds for SetLocalTime and SetSystemTime */
49 #define SETTIME_MAX_ADJUST 120
50 #define CALINFO_MAX_YEAR 2029
53 /***********************************************************************
54 * SetLocalTime (KERNEL32.@)
56 * Set the local time using current time zone and daylight
60 * Success: TRUE. The time was set
61 * Failure: FALSE, if the time was invalid or caller does not have
62 * permission to change the time.
64 BOOL WINAPI
SetLocalTime(
65 const SYSTEMTIME
*systime
) /* [in] The desired local time. */
68 LARGE_INTEGER st
, st2
;
71 SystemTimeToFileTime( systime
, &ft
);
72 st
.s
.LowPart
= ft
.dwLowDateTime
;
73 st
.s
.HighPart
= ft
.dwHighDateTime
;
74 RtlLocalTimeToSystemTime( &st
, &st2
);
76 if ((status
= NtSetSystemTime(&st2
, NULL
)))
77 SetLastError( RtlNtStatusToDosError(status
) );
82 /***********************************************************************
83 * GetSystemTimeAdjustment (KERNEL32.@)
85 * Get the period between clock interrupts and the amount the clock
86 * is adjusted each interrupt so as to keep it in sync with an external source.
92 * Only the special case of disabled time adjustments is supported.
94 BOOL WINAPI
GetSystemTimeAdjustment(
95 PDWORD lpTimeAdjustment
, /* [out] The clock adjustment per interupt in 100's of nanoseconds. */
96 PDWORD lpTimeIncrement
, /* [out] The time between clock interupts in 100's of nanoseconds. */
97 PBOOL lpTimeAdjustmentDisabled
) /* [out] The clock synchonisation has been disabled. */
99 *lpTimeAdjustment
= 0;
100 *lpTimeIncrement
= 0;
101 *lpTimeAdjustmentDisabled
= TRUE
;
106 /***********************************************************************
107 * SetSystemTime (KERNEL32.@)
109 * Set the system time in utc.
112 * Success: TRUE. The time was set
113 * Failure: FALSE, if the time was invalid or caller does not have
114 * permission to change the time.
116 BOOL WINAPI
SetSystemTime(
117 const SYSTEMTIME
*systime
) /* [in] The desired system time. */
123 SystemTimeToFileTime( systime
, &ft
);
124 t
.s
.LowPart
= ft
.dwLowDateTime
;
125 t
.s
.HighPart
= ft
.dwHighDateTime
;
126 if ((status
= NtSetSystemTime(&t
, NULL
)))
127 SetLastError( RtlNtStatusToDosError(status
) );
131 /***********************************************************************
132 * SetSystemTimeAdjustment (KERNEL32.@)
134 * Enables or disables the timing adjustments to the system's clock.
140 BOOL WINAPI
SetSystemTimeAdjustment(
141 DWORD dwTimeAdjustment
,
142 BOOL bTimeAdjustmentDisabled
)
144 /* Fake function for now... */
145 FIXME("(%08lx,%d): stub !\n", dwTimeAdjustment
, bTimeAdjustmentDisabled
);
150 /***********************************************************************
151 * GetTimeZoneInformation (KERNEL32.@)
153 * Get information about the current local time zone.
156 * Success: TIME_ZONE_ID_STANDARD. tzinfo contains the time zone info.
157 * Failure: TIME_ZONE_ID_INVALID.
159 DWORD WINAPI
GetTimeZoneInformation(
160 LPTIME_ZONE_INFORMATION tzinfo
) /* [out] Destination for time zone information */
163 if ((status
= RtlQueryTimeZoneInformation(tzinfo
)))
164 SetLastError( RtlNtStatusToDosError(status
) );
165 return TIME_ZONE_ID_STANDARD
;
169 /***********************************************************************
170 * SetTimeZoneInformation (KERNEL32.@)
172 * Change the settings of the current local time zone.
175 * Success: TRUE. The time zone was updated with the settings from tzinfo
178 BOOL WINAPI
SetTimeZoneInformation(
179 const LPTIME_ZONE_INFORMATION tzinfo
) /* [in] The new time zone. */
182 if ((status
= RtlSetTimeZoneInformation(tzinfo
)))
183 SetLastError( RtlNtStatusToDosError(status
) );
188 /***********************************************************************
189 * _DayLightCompareDate
191 * Compares two dates without looking at the year
195 * -1 if date < compareDate
196 * 0 if date == compareDate
197 * 1 if date > compareDate
198 * -2 if an error occures
201 static int _DayLightCompareDate(
202 const LPSYSTEMTIME date
, /* [in] The date to compare. */
203 const LPSYSTEMTIME compareDate
) /* [in] The daylight saving begin or end date */
207 if (compareDate
->wYear
!= 0)
209 if (date
->wMonth
< compareDate
->wMonth
)
210 return -1; /* We are in a year before the date limit. */
212 if (date
->wMonth
> compareDate
->wMonth
)
213 return 1; /* We are in a year after the date limit. */
216 if (date
->wMonth
< compareDate
->wMonth
)
217 return -1; /* We are in a month before the date limit. */
219 if (date
->wMonth
> compareDate
->wMonth
)
220 return 1; /* We are in a month after the date limit. */
222 if (compareDate
->wDayOfWeek
<= 6)
227 /* compareDate->wDay is interpreted as number of the week in the month. */
228 /* 5 means: the last week in the month */
229 int weekofmonth
= compareDate
->wDay
;
231 /* calculate day of week for the first day in the month */
232 memcpy(&tmp
, date
, sizeof(SYSTEMTIME
));
236 if (weekofmonth
== 5)
238 /* Go to the beginning of the next month. */
239 if (++tmp
.wMonth
> 12)
246 if (!SystemTimeToFileTime(&tmp
, &tmp_ft
))
249 if (weekofmonth
== 5)
253 t
= tmp_ft
.dwHighDateTime
;
255 t
+= (UINT
)tmp_ft
.dwLowDateTime
;
257 /* subtract one day */
262 tmp_ft
.dwLowDateTime
= (UINT
)t
;
263 tmp_ft
.dwHighDateTime
= (UINT
)(t
>> 32);
266 if (!FileTimeToSystemTime(&tmp_ft
, &tmp
))
269 if (weekofmonth
== 5)
271 /* calculate the last matching day of the week in this month */
272 int dif
= tmp
.wDayOfWeek
- compareDate
->wDayOfWeek
;
276 limit_day
= tmp
.wDay
- dif
;
280 /* calculate the matching day of the week in the given week */
281 int dif
= compareDate
->wDayOfWeek
- tmp
.wDayOfWeek
;
285 limit_day
= tmp
.wDay
+ 7*(weekofmonth
-1) + dif
;
290 limit_day
= compareDate
->wDay
;
293 if (date
->wDay
< limit_day
)
296 if (date
->wDay
> limit_day
)
299 return 0; /* date is equal to the date limit. */
303 /***********************************************************************
306 * Calculates the local time bias for a given time zone
310 * Returns TRUE when the time zone bias was calculated.
313 static BOOL
_GetTimezoneBias(
314 const LPTIME_ZONE_INFORMATION lpTimeZoneInformation
, /* [in] The time zone data. */
315 LPSYSTEMTIME lpSystemTime
, /* [in] The system time. */
316 LONG
* pBias
) /* [out] The calulated bias in minutes */
319 BOOL beforeStandardDate
, afterDaylightDate
;
320 BOOL daylightsaving
= FALSE
;
321 LONG bias
= lpTimeZoneInformation
->Bias
;
323 if (lpTimeZoneInformation
->DaylightDate
.wMonth
!= 0)
325 if (lpTimeZoneInformation
->StandardDate
.wMonth
== 0 ||
326 lpTimeZoneInformation
->StandardDate
.wDay
<1 ||
327 lpTimeZoneInformation
->StandardDate
.wDay
>5 ||
328 lpTimeZoneInformation
->DaylightDate
.wDay
<1 ||
329 lpTimeZoneInformation
->DaylightDate
.wDay
>5)
331 SetLastError(ERROR_INVALID_PARAMETER
);
335 /* check for daylight saving */
336 ret
= _DayLightCompareDate(lpSystemTime
, &lpTimeZoneInformation
->StandardDate
);
340 beforeStandardDate
= ret
< 0;
342 ret
= _DayLightCompareDate(lpSystemTime
, &lpTimeZoneInformation
->DaylightDate
);
346 afterDaylightDate
= ret
>= 0;
348 if (beforeStandardDate
&& afterDaylightDate
)
349 daylightsaving
= TRUE
;
353 bias
+= lpTimeZoneInformation
->DaylightBias
;
354 else if (lpTimeZoneInformation
->StandardDate
.wMonth
!= 0)
355 bias
+= lpTimeZoneInformation
->StandardBias
;
363 /***********************************************************************
364 * SystemTimeToTzSpecificLocalTime (KERNEL32.@)
366 * Convert a utc system time to a local time in a given time zone.
369 * Success: TRUE. lpLocalTime contains the converted time
373 BOOL WINAPI
SystemTimeToTzSpecificLocalTime(
374 LPTIME_ZONE_INFORMATION lpTimeZoneInformation
, /* [in] The desired time zone. */
375 LPSYSTEMTIME lpUniversalTime
, /* [in] The utc time to base local time on. */
376 LPSYSTEMTIME lpLocalTime
) /* [out] The local time in the time zone. */
381 TIME_ZONE_INFORMATION tzinfo
;
383 if (lpTimeZoneInformation
!= NULL
)
385 memcpy(&tzinfo
, lpTimeZoneInformation
, sizeof(TIME_ZONE_INFORMATION
));
389 if (GetTimeZoneInformation(&tzinfo
) == TIME_ZONE_ID_INVALID
)
393 if (!SystemTimeToFileTime(lpUniversalTime
, &ft
))
396 t
= ft
.dwHighDateTime
;
398 t
+= (UINT
)ft
.dwLowDateTime
;
400 if (!_GetTimezoneBias(&tzinfo
, lpUniversalTime
, &lBias
))
403 bias
= (LONGLONG
)lBias
* 600000000; /* 60 seconds per minute, 100000 [100-nanoseconds-ticks] per second */
406 ft
.dwLowDateTime
= (UINT
)t
;
407 ft
.dwHighDateTime
= (UINT
)(t
>> 32);
409 return FileTimeToSystemTime(&ft
, lpLocalTime
);
413 /***********************************************************************
414 * TzSpecificLocalTimeToSystemTime (KERNEL32.@)
416 * Converts a local time to a time in utc.
419 * Success: TRUE. lpUniversalTime contains the converted time
422 BOOL WINAPI
TzSpecificLocalTimeToSystemTime(
423 LPTIME_ZONE_INFORMATION lpTimeZoneInformation
, /* [in] The desired time zone. */
424 LPSYSTEMTIME lpLocalTime
, /* [in] The local time. */
425 LPSYSTEMTIME lpUniversalTime
) /* [out] The calculated utc time. */
430 TIME_ZONE_INFORMATION tzinfo
;
432 if (lpTimeZoneInformation
!= NULL
)
434 memcpy(&tzinfo
, lpTimeZoneInformation
, sizeof(TIME_ZONE_INFORMATION
));
438 if (GetTimeZoneInformation(&tzinfo
) == TIME_ZONE_ID_INVALID
)
442 if (!SystemTimeToFileTime(lpLocalTime
, &ft
))
445 t
= ft
.dwHighDateTime
;
447 t
+= (UINT
)ft
.dwLowDateTime
;
449 if (!_GetTimezoneBias(&tzinfo
, lpLocalTime
, &lBias
))
452 bias
= (LONGLONG
)lBias
* 600000000; /* 60 seconds per minute, 100000 [100-nanoseconds-ticks] per second */
455 ft
.dwLowDateTime
= (UINT
)t
;
456 ft
.dwHighDateTime
= (UINT
)(t
>> 32);
458 return FileTimeToSystemTime(&ft
, lpUniversalTime
);
462 /***********************************************************************
463 * GetSystemTimeAsFileTime (KERNEL32.@)
465 * Get the current time in utc format.
470 VOID WINAPI
GetSystemTimeAsFileTime(
471 LPFILETIME time
) /* [out] Destination for the current utc time */
474 NtQuerySystemTime( &t
);
475 time
->dwLowDateTime
= t
.s
.LowPart
;
476 time
->dwHighDateTime
= t
.s
.HighPart
;
480 /*********************************************************************
481 * TIME_ClockTimeToFileTime (olorin@fandra.org, 20-Sep-1998)
483 * Used by GetProcessTimes to convert clock_t into FILETIME.
485 * Differences to UnixTimeToFileTime:
486 * 1) Divided by CLK_TCK
487 * 2) Time is relative. There is no 'starting date', so there is
488 * no need for offset correction, like in UnixTimeToFileTime
490 static void TIME_ClockTimeToFileTime(clock_t unix_time
, LPFILETIME filetime
)
492 ULONGLONG secs
= RtlEnlargedUnsignedMultiply( unix_time
, 10000000 );
493 secs
= RtlExtendedLargeIntegerDivide( secs
, CLK_TCK
, NULL
);
494 filetime
->dwLowDateTime
= (DWORD
)secs
;
495 filetime
->dwHighDateTime
= (DWORD
)(secs
>> 32);
498 /*********************************************************************
499 * GetProcessTimes (KERNEL32.@)
501 * Get the user and kernel execution times of a process,
502 * along with the creation and exit times if known.
509 * Would be nice to subtract the cpu time used by Wine at startup.
510 * Also, there is a need to separate times used by different applications.
513 * lpCreationTime and lpExitTime are not initialised in the Wine implementation.
515 BOOL WINAPI
GetProcessTimes(
516 HANDLE hprocess
, /* [in] The process to be queried (obtained from PROCESS_QUERY_INFORMATION). */
517 LPFILETIME lpCreationTime
, /* [out] The creation time of the process. */
518 LPFILETIME lpExitTime
, /* [out] The exit time of the process if exited. */
519 LPFILETIME lpKernelTime
, /* [out] The time spent in kernal routines in 100's of nanoseconds. */
520 LPFILETIME lpUserTime
) /* [out] The time spent in user routines in 100's of nanoseconds. */
525 TIME_ClockTimeToFileTime(tms
.tms_utime
,lpUserTime
);
526 TIME_ClockTimeToFileTime(tms
.tms_stime
,lpKernelTime
);
530 /*********************************************************************
531 * GetCalendarInfoA (KERNEL32.@)
534 int WINAPI
GetCalendarInfoA(LCID lcid
, CALID Calendar
, CALTYPE CalType
,
535 LPSTR lpCalData
, int cchData
, LPDWORD lpValue
)
538 LPWSTR lpCalDataW
= NULL
;
540 FIXME("(%08lx,%08lx,%08lx,%p,%d,%p): quarter-stub\n",
541 lcid
, Calendar
, CalType
, lpCalData
, cchData
, lpValue
);
543 lcid
= ConvertDefaultLocale(lcid
);
545 if (NLS_IsUnicodeOnlyLcid(lcid
))
547 SetLastError(ERROR_INVALID_PARAMETER
);
552 !(lpCalDataW
= HeapAlloc(GetProcessHeap(), 0, cchData
*sizeof(WCHAR
))))
555 ret
= GetCalendarInfoW(lcid
, Calendar
, CalType
, lpCalDataW
, cchData
, lpValue
);
556 if(ret
&& lpCalDataW
&& lpCalData
)
557 WideCharToMultiByte(CP_ACP
, 0, lpCalDataW
, cchData
, lpCalData
, cchData
, NULL
, NULL
);
559 HeapFree(GetProcessHeap(), 0, lpCalDataW
);
564 /*********************************************************************
565 * GetCalendarInfoW (KERNEL32.@)
567 * See GetCalendarInfoA.
569 int WINAPI
GetCalendarInfoW(LCID Locale
, CALID Calendar
, CALTYPE CalType
,
570 LPWSTR lpCalData
, int cchData
, LPDWORD lpValue
)
572 FIXME("(%08lx,%08lx,%08lx,%p,%d,%p): quarter-stub\n",
573 Locale
, Calendar
, CalType
, lpCalData
, cchData
, lpValue
);
575 if (CalType
& CAL_NOUSEROVERRIDE
)
576 FIXME("flag CAL_NOUSEROVERRIDE used, not fully implemented\n");
577 if (CalType
& CAL_USE_CP_ACP
)
578 FIXME("flag CAL_USE_CP_ACP used, not fully implemented\n");
580 if (CalType
& CAL_RETURN_NUMBER
) {
581 if (lpCalData
!= NULL
)
582 WARN("lpCalData not NULL (%p) when it should!\n", lpCalData
);
584 WARN("cchData not 0 (%d) when it should!\n", cchData
);
587 WARN("lpValue not NULL (%p) when it should!\n", lpValue
);
590 /* FIXME: No verification is made yet wrt Locale
591 * for the CALTYPES not requiring GetLocaleInfoA */
592 switch (CalType
& ~(CAL_NOUSEROVERRIDE
|CAL_RETURN_NUMBER
|CAL_USE_CP_ACP
)) {
593 case CAL_ICALINTVALUE
:
594 FIXME("Unimplemented caltype %ld\n", CalType
& 0xffff);
597 FIXME("Unimplemented caltype %ld\n", CalType
& 0xffff);
599 case CAL_IYEAROFFSETRANGE
:
600 FIXME("Unimplemented caltype %ld\n", CalType
& 0xffff);
603 FIXME("Unimplemented caltype %ld\n", CalType
& 0xffff);
606 return GetLocaleInfoW(Locale
, LOCALE_SSHORTDATE
, lpCalData
, cchData
);
608 return GetLocaleInfoW(Locale
, LOCALE_SLONGDATE
, lpCalData
, cchData
);
610 return GetLocaleInfoW(Locale
, LOCALE_SDAYNAME1
, lpCalData
, cchData
);
612 return GetLocaleInfoW(Locale
, LOCALE_SDAYNAME2
, lpCalData
, cchData
);
614 return GetLocaleInfoW(Locale
, LOCALE_SDAYNAME3
, lpCalData
, cchData
);
616 return GetLocaleInfoW(Locale
, LOCALE_SDAYNAME4
, lpCalData
, cchData
);
618 return GetLocaleInfoW(Locale
, LOCALE_SDAYNAME5
, lpCalData
, cchData
);
620 return GetLocaleInfoW(Locale
, LOCALE_SDAYNAME6
, lpCalData
, cchData
);
622 return GetLocaleInfoW(Locale
, LOCALE_SDAYNAME7
, lpCalData
, cchData
);
623 case CAL_SABBREVDAYNAME1
:
624 return GetLocaleInfoW(Locale
, LOCALE_SABBREVDAYNAME1
, lpCalData
, cchData
);
625 case CAL_SABBREVDAYNAME2
:
626 return GetLocaleInfoW(Locale
, LOCALE_SABBREVDAYNAME2
, lpCalData
, cchData
);
627 case CAL_SABBREVDAYNAME3
:
628 return GetLocaleInfoW(Locale
, LOCALE_SABBREVDAYNAME3
, lpCalData
, cchData
);
629 case CAL_SABBREVDAYNAME4
:
630 return GetLocaleInfoW(Locale
, LOCALE_SABBREVDAYNAME4
, lpCalData
, cchData
);
631 case CAL_SABBREVDAYNAME5
:
632 return GetLocaleInfoW(Locale
, LOCALE_SABBREVDAYNAME5
, lpCalData
, cchData
);
633 case CAL_SABBREVDAYNAME6
:
634 return GetLocaleInfoW(Locale
, LOCALE_SABBREVDAYNAME6
, lpCalData
, cchData
);
635 case CAL_SABBREVDAYNAME7
:
636 return GetLocaleInfoW(Locale
, LOCALE_SABBREVDAYNAME7
, lpCalData
, cchData
);
637 case CAL_SMONTHNAME1
:
638 return GetLocaleInfoW(Locale
, LOCALE_SMONTHNAME1
, lpCalData
, cchData
);
639 case CAL_SMONTHNAME2
:
640 return GetLocaleInfoW(Locale
, LOCALE_SMONTHNAME2
, lpCalData
, cchData
);
641 case CAL_SMONTHNAME3
:
642 return GetLocaleInfoW(Locale
, LOCALE_SMONTHNAME3
, lpCalData
, cchData
);
643 case CAL_SMONTHNAME4
:
644 return GetLocaleInfoW(Locale
, LOCALE_SMONTHNAME4
, lpCalData
, cchData
);
645 case CAL_SMONTHNAME5
:
646 return GetLocaleInfoW(Locale
, LOCALE_SMONTHNAME5
, lpCalData
, cchData
);
647 case CAL_SMONTHNAME6
:
648 return GetLocaleInfoW(Locale
, LOCALE_SMONTHNAME6
, lpCalData
, cchData
);
649 case CAL_SMONTHNAME7
:
650 return GetLocaleInfoW(Locale
, LOCALE_SMONTHNAME7
, lpCalData
, cchData
);
651 case CAL_SMONTHNAME8
:
652 return GetLocaleInfoW(Locale
, LOCALE_SMONTHNAME8
, lpCalData
, cchData
);
653 case CAL_SMONTHNAME9
:
654 return GetLocaleInfoW(Locale
, LOCALE_SMONTHNAME9
, lpCalData
, cchData
);
655 case CAL_SMONTHNAME10
:
656 return GetLocaleInfoW(Locale
, LOCALE_SMONTHNAME10
, lpCalData
, cchData
);
657 case CAL_SMONTHNAME11
:
658 return GetLocaleInfoW(Locale
, LOCALE_SMONTHNAME11
, lpCalData
, cchData
);
659 case CAL_SMONTHNAME12
:
660 return GetLocaleInfoW(Locale
, LOCALE_SMONTHNAME12
, lpCalData
, cchData
);
661 case CAL_SMONTHNAME13
:
662 return GetLocaleInfoW(Locale
, LOCALE_SMONTHNAME13
, lpCalData
, cchData
);
663 case CAL_SABBREVMONTHNAME1
:
664 return GetLocaleInfoW(Locale
, LOCALE_SABBREVMONTHNAME1
, lpCalData
, cchData
);
665 case CAL_SABBREVMONTHNAME2
:
666 return GetLocaleInfoW(Locale
, LOCALE_SABBREVMONTHNAME2
, lpCalData
, cchData
);
667 case CAL_SABBREVMONTHNAME3
:
668 return GetLocaleInfoW(Locale
, LOCALE_SABBREVMONTHNAME3
, lpCalData
, cchData
);
669 case CAL_SABBREVMONTHNAME4
:
670 return GetLocaleInfoW(Locale
, LOCALE_SABBREVMONTHNAME4
, lpCalData
, cchData
);
671 case CAL_SABBREVMONTHNAME5
:
672 return GetLocaleInfoW(Locale
, LOCALE_SABBREVMONTHNAME5
, lpCalData
, cchData
);
673 case CAL_SABBREVMONTHNAME6
:
674 return GetLocaleInfoW(Locale
, LOCALE_SABBREVMONTHNAME6
, lpCalData
, cchData
);
675 case CAL_SABBREVMONTHNAME7
:
676 return GetLocaleInfoW(Locale
, LOCALE_SABBREVMONTHNAME7
, lpCalData
, cchData
);
677 case CAL_SABBREVMONTHNAME8
:
678 return GetLocaleInfoW(Locale
, LOCALE_SABBREVMONTHNAME8
, lpCalData
, cchData
);
679 case CAL_SABBREVMONTHNAME9
:
680 return GetLocaleInfoW(Locale
, LOCALE_SABBREVMONTHNAME9
, lpCalData
, cchData
);
681 case CAL_SABBREVMONTHNAME10
:
682 return GetLocaleInfoW(Locale
, LOCALE_SABBREVMONTHNAME10
, lpCalData
, cchData
);
683 case CAL_SABBREVMONTHNAME11
:
684 return GetLocaleInfoW(Locale
, LOCALE_SABBREVMONTHNAME11
, lpCalData
, cchData
);
685 case CAL_SABBREVMONTHNAME12
:
686 return GetLocaleInfoW(Locale
, LOCALE_SABBREVMONTHNAME12
, lpCalData
, cchData
);
687 case CAL_SABBREVMONTHNAME13
:
688 return GetLocaleInfoW(Locale
, LOCALE_SABBREVMONTHNAME13
, lpCalData
, cchData
);
690 return GetLocaleInfoW(Locale
, LOCALE_SYEARMONTH
, lpCalData
, cchData
);
691 case CAL_ITWODIGITYEARMAX
:
692 if (lpValue
) *lpValue
= CALINFO_MAX_YEAR
;
694 default: MESSAGE("Unknown caltype %ld\n",CalType
& 0xffff);
700 /*********************************************************************
701 * SetCalendarInfoA (KERNEL32.@)
704 int WINAPI
SetCalendarInfoA(LCID Locale
, CALID Calendar
, CALTYPE CalType
, LPCSTR lpCalData
)
706 FIXME("(%08lx,%08lx,%08lx,%s): stub\n",
707 Locale
, Calendar
, CalType
, debugstr_a(lpCalData
));
711 /*********************************************************************
712 * SetCalendarInfoW (KERNEL32.@)
714 * See SetCalendarInfoA.
716 int WINAPI
SetCalendarInfoW(LCID Locale
, CALID Calendar
, CALTYPE CalType
, LPCWSTR lpCalData
)
718 FIXME("(%08lx,%08lx,%08lx,%s): stub\n",
719 Locale
, Calendar
, CalType
, debugstr_w(lpCalData
));
723 /*********************************************************************
724 * LocalFileTimeToFileTime (KERNEL32.@)
726 BOOL WINAPI
LocalFileTimeToFileTime( const FILETIME
*localft
, LPFILETIME utcft
)
729 LARGE_INTEGER local
, utc
;
731 local
.s
.LowPart
= localft
->dwLowDateTime
;
732 local
.s
.HighPart
= localft
->dwHighDateTime
;
733 if (!(status
= RtlLocalTimeToSystemTime( &local
, &utc
)))
735 utcft
->dwLowDateTime
= utc
.s
.LowPart
;
736 utcft
->dwHighDateTime
= utc
.s
.HighPart
;
738 else SetLastError( RtlNtStatusToDosError(status
) );
743 /*********************************************************************
744 * FileTimeToLocalFileTime (KERNEL32.@)
746 BOOL WINAPI
FileTimeToLocalFileTime( const FILETIME
*utcft
, LPFILETIME localft
)
749 LARGE_INTEGER local
, utc
;
751 utc
.s
.LowPart
= utcft
->dwLowDateTime
;
752 utc
.s
.HighPart
= utcft
->dwHighDateTime
;
753 if (!(status
= RtlSystemTimeToLocalTime( &utc
, &local
)))
755 localft
->dwLowDateTime
= local
.s
.LowPart
;
756 localft
->dwHighDateTime
= local
.s
.HighPart
;
758 else SetLastError( RtlNtStatusToDosError(status
) );
763 /*********************************************************************
764 * FileTimeToSystemTime (KERNEL32.@)
766 BOOL WINAPI
FileTimeToSystemTime( const FILETIME
*ft
, LPSYSTEMTIME syst
)
771 t
.s
.LowPart
= ft
->dwLowDateTime
;
772 t
.s
.HighPart
= ft
->dwHighDateTime
;
773 RtlTimeToTimeFields(&t
, &tf
);
775 syst
->wYear
= tf
.Year
;
776 syst
->wMonth
= tf
.Month
;
778 syst
->wHour
= tf
.Hour
;
779 syst
->wMinute
= tf
.Minute
;
780 syst
->wSecond
= tf
.Second
;
781 syst
->wMilliseconds
= tf
.Milliseconds
;
782 syst
->wDayOfWeek
= tf
.Weekday
;
786 /*********************************************************************
787 * SystemTimeToFileTime (KERNEL32.@)
789 BOOL WINAPI
SystemTimeToFileTime( const SYSTEMTIME
*syst
, LPFILETIME ft
)
794 tf
.Year
= syst
->wYear
;
795 tf
.Month
= syst
->wMonth
;
797 tf
.Hour
= syst
->wHour
;
798 tf
.Minute
= syst
->wMinute
;
799 tf
.Second
= syst
->wSecond
;
800 tf
.Milliseconds
= syst
->wMilliseconds
;
802 RtlTimeFieldsToTime(&tf
, &t
);
803 ft
->dwLowDateTime
= t
.s
.LowPart
;
804 ft
->dwHighDateTime
= t
.s
.HighPart
;
808 /*********************************************************************
809 * CompareFileTime (KERNEL32.@)
811 * Compare two FILETIME's to each other.
815 * y [I] time to compare to x
818 * -1, 0, or 1 indicating that x is less than, equal to, or greater
819 * than y respectively.
821 INT WINAPI
CompareFileTime( const FILETIME
*x
, const FILETIME
*y
)
823 if (!x
|| !y
) return -1;
825 if (x
->dwHighDateTime
> y
->dwHighDateTime
)
827 if (x
->dwHighDateTime
< y
->dwHighDateTime
)
829 if (x
->dwLowDateTime
> y
->dwLowDateTime
)
831 if (x
->dwLowDateTime
< y
->dwLowDateTime
)
836 /*********************************************************************
837 * GetLocalTime (KERNEL32.@)
839 * Get the current local time.
844 VOID WINAPI
GetLocalTime(LPSYSTEMTIME systime
) /* [O] Destination for current time */
847 LARGE_INTEGER ft
, ft2
;
849 NtQuerySystemTime(&ft
);
850 RtlSystemTimeToLocalTime(&ft
, &ft2
);
851 lft
.dwLowDateTime
= ft2
.s
.LowPart
;
852 lft
.dwHighDateTime
= ft2
.s
.HighPart
;
853 FileTimeToSystemTime(&lft
, systime
);
856 /*********************************************************************
857 * GetSystemTime (KERNEL32.@)
859 * Get the current system time.
864 VOID WINAPI
GetSystemTime(LPSYSTEMTIME systime
) /* [O] Destination for current time */
869 NtQuerySystemTime(&t
);
870 ft
.dwLowDateTime
= t
.s
.LowPart
;
871 ft
.dwHighDateTime
= t
.s
.HighPart
;
872 FileTimeToSystemTime(&ft
, systime
);