GetTimeZone

Discussion in 'Share Your Creations' started by alfcen, Oct 5, 2007.

  1. alfcen

    alfcen Well-Known Member Licensed User

    Hi everybody,
    Here are the routines for retrieving the Time Zone.
    Tested with PPC2003SE, not tested under WM5.x/6.x.
    Tested on desktop with XP Home Edition.
    Perhaps there is a more elegant solution involving less code.
    Please use or abuse:)
    (transferred from the Wishlist)

    Code:
    Sub App_Start
      Reg.New1     
    'registry.dll
      Bit.New1      'bitwise.dll
    End Sub

    Sub Globals
      
    Dim zti(0As Byte      'Array for binary data (PPC), registry entry is binary
    End Sub

    Sub GetTimeZone
      
    Dim m, i
      Reg.RootKey(Reg.rtLocalMachine)
      
    If CPPC = True Then
        zti()=Reg.GetValue(
    "Time","TimeZoneInformation")
        
    For i = 3 To 0 Step -1
          m = m & 
    bit.DecToHex(zti(i))
        
    Next
        
    Return bit.HexToDec(m) / 60 * (-1)
      
    Else
        m = Reg.GetValue(
    "System\CurrentControlSet\Control\Tim eZoneInformation","ActiveTimeBias")
      
    Return m / 60 * (-1)
      
    End If 
    End Sub

    Sub GetDayLightSavingHour
      
    'for the desktop only
      Return Reg.GetValue("System\CurrentControlSet\Control\Tim eZoneInformation","StandardBias")
    End Sub
     
  2. dzt

    dzt Active Member Licensed User

    Hi Robert,

    :sign0098:

    Works OK for me (tested in two different WM5 devices).
     
  3. alfcen

    alfcen Well-Known Member Licensed User

    Hi Dimitris
    Thanks a lot for testing and your feedback. Good knowing everything works on various platforms.
    Cheers
    Robert
     
  4. Roman

    Roman Member Licensed User

    cut & copy error

    :sign0098: :sign0161:

    You get error when you cut&paste on line nr 20:
    ....."rrentContolSet\Control\TimeZon eInformation".......
    shuld be
    ....."rrentContolSet\Control\TimeZoneInformation".......


    Erel. Please change size of message window in forum.
     
    Last edited: Oct 8, 2007
  5. alfcen

    alfcen Well-Known Member Licensed User

    Sorry about that, Roman, I am using Japanese XP and the B4PPC editor switches from alphabet to Japanese mode after almost every Run, thus leaving double-byte characters behind. Fortunately, the compiler identifies them as syntax error, but hunting for a double-byte space is like looking for a needle in a haystack. :sign0080:

    Thanks for your feedback.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice