[thelist] meo GMT Offset

Paul Cowan evolt at funkwit.com
Sun Jun 23 20:02:00 CDT 2002


Hey Lach,

> What dates, exactly? First of both months? I really need to take the
> hardwiring out of my code and replace it with something that'll adjust for
> daylight savings.

In ASP, you can use the following nifty-wifty functions that I wrote.
BASE_TIME_ZONE is defined as "10" for Melbourne time. You can adjust as you
see fit (well... YOU'LL want 10, but other people mightn't...)

You'll also need the TimeZoneOffset() function from
<http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=4&txtCodeI
d=6314>

To get the current Melbourne time (regardless of where your server is), call
GetCorrectedTime(). To correct a specific time, use the CorrectTime()
function, with GetTimeZone() usually the last argument.

Caveat: it doesn't cope with DST as far as *Melbourne* time goes. It does as
far as the server goes though. That's coming soon. You can always correct to
UTC, then it doesn't matter.

If you're not using ASP, well.... bad luck! Might be able to get something
out of it though.

Paul

<%
    const BASE_TIME_ZONE = 10


 function CorrectTime(datOriginal, dblZoneCorrectTo, dblZoneCorrectFrom)
  dim datGMT
  dim datCorrected

  datGMT = dateadd("h", 0 - dblZoneCorrectFrom, datOriginal)
  datCorrected = dateadd("h", dblZoneCorrectTo, datGMT)

  CorrectTime = datCorrected
 end function

 function GetCorrectedTime()
  GetCorrectedTime = CorrectTime(now(), BASE_TIME_ZONE, TimezoneOffset())
 end function

%>





More information about the thelist mailing list