Detecting Daylight Savings Time

Discussion in 'Software' started by jkgraham, Jan 7, 2009.

  1. jkgraham

    jkgraham Private E-2

    I need to write VBA code that detects when Windows adjusts a computers clock for Daylight Savings Time. Or weather Daylight Savings Time is "On" or "Off".

    Is there a method of retriving this information from WIndows?

    The operating system is Windows XP SP 2
     
  2. jkgraham

    jkgraham Private E-2

    FYI: I posted the same question on the MSDN Forums and here are some of the information posted there
    ______________________________________________________________
    I have found this in the registry:
    HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\TimeZoneInformation
    ActiveTimeBias REG_DWORD 0x00000168(360)
    Bias REG_DWORD 0x00000168(360)
    DaylightBias REG_DWORD oxffffffc4(4294967236)
    DaylightName REG_SZ Central Daylight Time
    DaylightStart REG_BINARY 00 00 03 00 02 00 02 00 00 00 00 00 00 00 00 00
    StandardBias REG_DWORD 0x00000000 (0)
    StandardName REG_SZ Central Standard Time
    StandardStart REG_BINARY 00 00 0b 00 01 00 02 00 00 00 00 00 00 00 00 00

    U.S. Daylight Saving Time Schedule
    2007: March 11 - Nov. 4
    2008: March 9 - Nov. 2
    2009: March 8 - Nov. 1
    2010: March 14 - Nov. 7
    2011: March 13 - Nov. 6

    Therefore it appears to me that registry key is read as follows:
    DaylightStart REG_BINARY 00 00 03 00 02 00 02 00 00 00 00 00 00 00 00 00
    03 = March
    02 = Second Sunday?
    02 = 2am

    _______________________________________________________________

    This web site might help:

    http://www.netadmintools.com/art575.html


    _______________________________________________________________

    How about .IsDaylightSavingsTime of the Date object:

    http://msdn.microsoft.com/en-us/library/system.datetime.isdaylightsavingtime.aspx

    _______________________________________________________________
    If you want to know about the machine the code is running on, and assuming the time is correct then, as stephen said use IsDaylightSavingTime. it should be available in most Microsoft languages.
    Dim isDST As Boolean
    isDST = DateTime.Parse("7/29/2009").IsDaylightSavingTime
    isDST = DateTime.Now.IsDaylightSavingTime
    'or
    If DateTime.Parse("7/29/2009").IsDaylightSavingTime Then
    'is DST
    Else
    'not DST
    End If
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds