2 Attachment(s)
[RESOLVED] New Daylight Savings Time Problem
Hello, I am attaching an application that calculates the DST dates. I used this example from vbnet:
http://vbnet.mvps.org/index.html?cod...neforecast.htm
As you can see from the image, on my WinXp computer using Eastern Time Zone (-0500 GMT) it calculates the DST to be March 4th instead of March 11th.
Anybody know what could be wrong? Thank you.
Re: New Daylight Savings Time Problem
Did you apply the Hotfix as DST has been changed to a new starting date.
Re: New Daylight Savings Time Problem
Yes I have applied all the latest patches and hotfixes. Win XP Service Pack 2 with all patches. But when I run that code it returns March 4th instead of March 11th like in the image.
Re: New Daylight Savings Time Problem
Re: New Daylight Savings Time Problem
Thanks RobDog888, I had seen that page and the results are still the same. I tried Home User and I tried Software Developer.
However it still doesn't explain why the above code would return March 4th and also for subsequent years as you can see in my posted image. Have you tried the code from vbnet? Does it return also March 4th on your machine?
From the microsoft site for developers concerning DST:
http://msdn2.microsoft.com/en-us/vstudio/bb264729.aspx
Quote:
After the DST update, versions of Windows prior to Windows Vista will have DST values that are correct for 2007 onwards but historical DST values may not be.
Re: New Daylight Savings Time Problem
If you try
vb Code:
tmp = DateSerial(tziYear, _
.wMonth, _
(.wDayOfWeek - MonthFirstWeekday + _
.wDay * 7) Mod 7 + 1 + (7 * (.wDay - 1)))
in GetTimezoneChangeDate you should get the correct dates. (There must be a way to simplify it, but I'm too tired to think.)
Re: New Daylight Savings Time Problem
Thank you very much Al42. Your help is much appreciated. It works now.
Out of curiosity, what is your logic for adding this?
Code:
+ (7 * (.wDay - 1))
Re: [RESOLVED] New Daylight Savings Time Problem
Empirical Engineering. :)
The original result was always the first Sunday of the month, regardless of what .wDay was, so we had to add 7 * (the number of weeks - 1).
On further reflection
vb Code:
tmp = DateSerial(tziYear, _
.wMonth, _
(.wDayOfWeek - MonthFirstWeekday + _
.wDay * 7) + 1)
is a much simpler solution - instead of fixing the error, just don't cause it in the first place.
Re: [RESOLVED] New Daylight Savings Time Problem
Thanks again Al42.
But would this work for all timezones or just the US timezones?
Should I also add the same code to the second part in Week 5?
Code:
Case 5: 'last week in month
'Calculate the month's last day,
'then work back to the appropriate
'weekday
tmp = DateSerial(tziYear, .wMonth + 1, 0)
tmp = DateAdd("d", tmp, -(Weekday(tmp) - .wDayOfWeek + 7 - 1) Mod 7)
Re: [RESOLVED] New Daylight Savings Time Problem
Quote:
Originally Posted by Hassan Basri
But would this work for all timezones or just the US timezones?
It will work to get the first, second, etc., Sunday (or whichever day you want) from the structure it's being fed, but I have no idea whether Windows will give you the correct details about what the change dates are (first Sunday in March, second Tuesday in May, whatever) for other countries.
Quote:
Should I also add the same code to the second part in Week 5?
That one seems to not only work properly for the 5th week, if the month has 4 weeks you'll get the same date for week 4 and week 5 (which is technically wrong, but conceptually [the concept is "last day", not that day in the 5th week] correct). So don't change it.
Re: [RESOLVED] New Daylight Savings Time Problem
Thank you my friend you have really helped me out here.
P.S.
I tried giving you a reputation point but got this message:
You must spread some Reputation around before giving it to Al42 again.