Jeff King wrote
Events module v3.2.0 on DNN 3.2.2. When user clicks to "Export Event to Desktop Event" (personal calendar such as Outlook, Palm Desktop, it does not handle Daylight Saving Time.
All was fine converting an event to UTC prior to daylight savings time went into effect. But any event that falls inside the time period of daylight saving time is exported to local calendar 1 hour off. It does not matter what day it is now, it matters what the date of the event is.
I have a partial solution. This does not solve it for world wide timezones or places in US where DST is not employed such as Hawaii, eastern IN and most of Arizona. For these cases, the prior behavior exists. That is, no DST offset is considered.
In file EventController:
Public Function ConvertDateTimeToTZ(ByVal FromDateTime As DateTime, ByVal FromTZ As Integer, ByVal ToTZ As Integer) As DateTime
' JJK. need to subtract minutes for Daylight Saving Time.
' So, check the FromTZ and determine what TimeZone that is, then check the start/end dates of DST.
' If date is between then subtract minutes.
' Since there is no way to instantiate a specific TimeZone, let's assume the timezone supports DST
' This is a problem in Arizona (-420), Hawaii (-600) and eastern Indiana (-300). So, always add the offset.
Dim dstOffset As Double
If ToTZ = 0 Then
' Must apply Daylight Saving Time offset.
Dim tz As TimeZone = TimeZone.CurrentTimeZone ' Timezone of the server
If tz.IsDaylightSavingTime(FromDateTime) Then ' TODO: need to determine if DST based on FromTZ, not server timezone.
Dim daylight As DaylightTime = tz.GetDaylightChanges(DateTime.Now.Year)
dstOffset = daylight.Delta.TotalMinutes() ' assumes DST offset is same for target as it is for this server (60 mins). Is this true for all areas/countries?
Else
dstOffset = 0
End If
Else
' Converting from 1 timezone to another. Assume DST is applied in both
' and therefore, no DST offset is needed.
' This is a problem if converting FROM or TO a timezone that does not support DST when the other does.
dstOffset = 0
End If
Return FromDateTime.AddMinutes(Convert.ToDouble(ToTZ) - Convert.ToDouble(FromTZ) - dstOffset)
End Function
Hi Jeff,
I really need to implement this and I'm having a bit of trouble just finding the file. I downloaded the source for the Event module and I don't see any project files to open in visual studio. Any help you might be able to offer would be great.
Thank you,
Derek