Changes made to wince-compatibility.c to enable
tm_isdst flag.
513a515,518
>
> TIME_ZONE_INFORMATION tzinfo;
> int nIsdst = (GetTimeZoneInformation(&tzinfo)
==TIME_ZONE_ID_DAYLIGHT)?1:0;
>
536a542,544
>
>
>
544c552,556
< tm.tm_yday = Day_Of_Year_By_Month[tm.tm_mon]
+ tm.tm_mday - 1;
---
> tm.tm_yday = Day_Of_Year_By_Month[tm.tm_mon]
+ tm.tm_mday - 1;
> tm.tm_isdst = nIsdst;
>
Logged In: YES
user_id=859104
The original proposed fix is somewhat deficient - although
it served my immedidate requirements... of course it
returns the dst for *now* only.
The changes below are more general (but not rigorous see
comments).
508a510,579
> static int Zeller (int d, int m, int y)
> {
> if (m <= 2)
> {
> y--;
> m += 12;
> }
> return (d+(m*2)+(int)((m+1)*3.0/5.0)+y+y/4-
y/100+y/400+1)%7 + 1;
> }
>
>
> static int GetSundayOfMonth(SYSTEMTIME t,int nYear)
> {
> if (t.wDay == 5)
> {
> //Warning does not handle leap years
> int Months[12] =
{31,28,31,30,31,30,31,31,30,31,30,31};
> return Months[t.wMonth-1]-(Zeller(Months
[t.wMonth-1],t.wMonth,nY
ear)-1);
> }
> else
> {
> return (9-Zeller(1,t.wMonth,nYear))%9+(7*
(t.wDay-1));
> }
> }
>
> short IsDST(SYSTEMTIME time)
> {
>
> TIME_ZONE_INFORMATION tzinfo;
> SYSTEMTIME stDaylightWeekInMonth;
> SYSTEMTIME stStandardWeekInMonth;
> int nDaylightSunday;
> int nStandardSunday;
> SYSTEMTIME stDaylightAbsolute;
> FILETIME ftDaylight;
> SYSTEMTIME stStandardAbsolute;
> FILETIME ftStandard;
> FILETIME ftTime;
>
> GetTimeZoneInformation(&tzinfo);
> stDaylightWeekInMonth = tzinfo.DaylightDate;
> stStandardWeekInMonth = tzinfo.StandardDate;
>
> nDaylightSunday = GetSundayOfMonth
(stDaylightWeekInMonth,time.wYear);
> nStandardSunday = GetSundayOfMonth
(stStandardWeekInMonth,time.wYear);
>
> stDaylightAbsolute.wYear = time.wYear;
> stDaylightAbsolute.wMonth =
stDaylightWeekInMonth.wMonth;
> stDaylightAbsolute.wDay = nDaylightSunday;
> stDaylightAbsolute.wHour =
stDaylightWeekInMonth.wHour;
> stDaylightAbsolute.wMinute =
stDaylightWeekInMonth.wMinute;
> stDaylightAbsolute.wSecond =
stDaylightWeekInMonth.wSecond;
> stDaylightAbsolute.wMilliseconds = 0;
> SystemTimeToFileTime
(&stDaylightAbsolute,&ftDaylight);
>
> stStandardAbsolute.wYear = time.wYear;
> stStandardAbsolute.wMonth =
stStandardWeekInMonth.wMonth;
> stStandardAbsolute.wDay = nStandardSunday;
> stStandardAbsolute.wHour =
stStandardWeekInMonth.wHour;
> stStandardAbsolute.wMinute =
stStandardWeekInMonth.wMinute;
> stStandardAbsolute.wSecond =
stStandardWeekInMonth.wSecond;
> stStandardAbsolute.wMilliseconds = 0;
> SystemTimeToFileTime
(&stStandardAbsolute,&ftStandard);
>
> SystemTimeToFileTime(&time,&ftTime);
>
> return ( (CompareFileTime(&ftTime,&ftDaylight)==1)
&& (CompareFileTime(&ftTime,&ftStandard)!=1) );
> }
>
>
536a608
>
544c616,620
< tm.tm_yday = Day_Of_Year_By_Month[tm.tm_mon] +
tm.tm_mday - 1;
---
> tm.tm_yday = Day_Of_Year_By_Month[tm.tm_mon] +
tm.tm_mday - 1;
> tm.tm_isdst = IsDST(System_Time);
>
>