Is it daylight savings tomorrow?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi, having some issues with this one.
I need to write some code to tell the user when daylight savings starts and ends in another timezone, this is what I came up with but it keeps selecting the last
Else line. The other lines are working fine, the problem is only with the lines, daylight savings today and not tomorrow. There is probably a much neater way of doing this but I thought this would work.
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Private <span style="color:Blue; Sub Auto_Time_Change()
<span style="color:Blue; Dim sydneyTime <span style="color:Blue; As TimeZoneInfo = (TimeZoneInfo.FindSystemTimeZoneById(<span style="color:#A31515; "AUS Eastern Standard Time"))
<span style="color:Blue; If TSSlblTimeZone.Text = <span style="color:#A31515; "Normal Time" <span style="color:Blue; Then
<span style="color:Blue; If CurDate.AddDays(1).Day = <span style="color:#A31515; "1" <span style="color:Blue; Then
TSSlblSpecial.Text = <span style="color:#A31515; "End Of Month - 22:00 Start / 20:00 Finish 22hr Day"
<span style="color:Blue; ElseIf CurDate.Day = <span style="color:#A31515; "1" <span style="color:Blue; Then
TSSlblSpecial.Text = <span style="color:#A31515; "Start Of Month - 20:00 Start / 22:00 Finish 26hr Day"
<span style="color:Blue; ElseIf ((sydneyTime.IsDaylightSavingTime(Today)) = <span style="color:Blue; False) <span style="color:Blue; And ((sydneyTime.IsDaylightSavingTime(Today.AddDays(1)) = <span style="color:Blue; True)) <span style="color:Blue; Then
TSSlblSpecial.Text = <span style="color:#A31515; "Start Of Daylight Savings - 22:00 Start / 21:00 Finish 23hr Day"
<span style="color:Blue; Else : TSSlblSpecial.Text = <span style="color:#A31515; "22:00 Start / 22:00 Finish 24hr Day"
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; ElseIf TSSlblTimeZone.Text = <span style="color:#A31515; "Daylight Savings Time" <span style="color:Blue; Then
<span style="color:Blue; If CurDate.AddDays(1).Day = <span style="color:#A31515; "1" <span style="color:Blue; Then
TSSlblSpecial.Text = <span style="color:#A31515; "End Of Month - 21:00 Start / 19:00 Finish 22hr Day"
<span style="color:Blue; ElseIf CurDate.Day = <span style="color:#A31515; "1" <span style="color:Blue; Then
TSSlblSpecial.Text = <span style="color:#A31515; "Start Of Month - 19:00 Start / 21:00 Finish 26hr Day"
<span style="color:Blue; ElseIf ((sydneyTime.IsDaylightSavingTime(Today)) = <span style="color:Blue; True) <span style="color:Blue; And ((sydneyTime.IsDaylightSavingTime(Today.AddDays(1)) = <span style="color:Blue; False)) <span style="color:Blue; Then
TSSlblSpecial.Text = <span style="color:#A31515; "End Of Daylight Savings - 21:00 Start / 22:00 Finish 25hr Day"
<span style="color:Blue; Else : TSSlblSpecial.Text = <span style="color:#A31515; "21:00 Start / 21:00 Finish 24hr Day"
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; End <span style="color:Blue; Sub
[/code]
Can anyone let me know what I am doing wrong or how I can do this easier or a better way?
Thanks.
Arg.

View the full article
 
Back
Top