rip747 / TimeZone-CFC

A component that will take a timestamp from a timezone and convert it to and from utc. It will also a utc timestamp and convert it to the local time in a timezone. All this while taking Daylight Savings time into account. This is all done using the java.util.TimeZone class.
17 stars 7 forks source link

getTZOffset returns inaccurate information #1

Open rip747 opened 14 years ago

rip747 commented 14 years ago

The getTZOffset function returns invalid data if you are returning the offset for the same day that the time changed (like today, nov 2, 2008)

This is because on line 123 when getOffset() is called the last param is set to '0' when infact it should be set to '3600000' since time does not officially change on that day until 1AM.

So to fix it line 123 should read: <cfreturn timezone.getOffset(1, tYear, tMonth, tDay, tDOW, 3600000) / 3600000>

Hope this helps someone else, I was pulling my hair out over it today.

rip747 commented 14 years ago

Comment by brannon.hightower (Brannon Hightower) : 03/03/09 10:00 AM Thought the Time change was at 2AM. Well regardless you dont need to hard code the miliseconds like here

if you add to the code: <cfset var startDate = createDateTime(year(arguments.thisDate),month(arguments.thisDate),day(arguments.thisDate),'00','00','00')> <cfset var tMil = dateDiff("s",startDate,arguments.thisDate) * 1000>

and change the cfreturn to this:

<cfreturn timezone.getOffset(1, tYear, tMonth, tDay, tDOW, tMil) / 3600000> that should do the trick

mlncn commented 12 years ago

Was this change merged in? Unfortunately, here in the comments, GitHub is not displaying the example code, not even in source.