Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Daylight Savings Time Function

Status
Not open for further replies.

JSpicolli

Programmer
Apr 2, 2004
208
US
Anyone got a function that will return a bool, depending on if Eastern time is currently on Daylight Savings time?

I need to convert EST to GMT, but the offset differs by an hour depending on if we are on Daylight Savings Time or not.

GMT_OFFSET = 5
IncidentTime = dateAdd("h", GMT_OFFSET, TIME)


Muchos Gracias
 
haven't tried this but just thinking while typing...

could you write something to scrape (look for this text 'Clocks in Europe / USA / Canada on Summer / Daylight Saving Time until 30th October 2005' -- or even just part of it) and then apply your offset?

like i said...haven't written/tested anything...just a thought.
 
In case anyone else ever needs this functionality:

Code:
<% 
    ' fill in your known bias here! 
 
    offset = 5 
 
    ' find first Sunday in April 
 
    for i = 1 to 7 
        if weekday("4/" & i & "/2001")=1 then 
            startDST = cdate("4/" & i & "/2001") 
            exit for 
        end if 
    next 
 
    ' find last Sunday in October 
 
    for i = 31 to 25 step -1 
        if weekday("10/" & i & "/2001")=1 then 
            endDST = cdate("10/" & i & "/2001") 
            exit for 
        end if 
    next 
 
    ' set some arbitrary date 
 
    od = "06/28/2001 4:35:08 AM" 
 
    ' subtract hour from offset if within DST 
 
    if cdate(od) >= startDST and cdate(od) < endDST then 
        offset = offset - 1 
    end if 
 
    nd = dateadd("h", offset, od) 
     
    Response.Write("Current = " & od & "<Br>UTC = " & nd) 
%>

 
I haven't checked yet, but looks like startDST and endDST must be greater for 2 hours (change occurs at 02:00AM).

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Nice function - unfortunately only works in a few parts of the world. Not even the whole US agrees on DST settings. A page related to your previous ( gives some clues, but misses out large chunks of the world. A (slightly) more comprehensive list:

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
Essex Steam UK for steam enthusiasts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top