Time Zone

Discussion in 'Basic4ppc Wishlist' started by alfcen, Oct 2, 2007.

  1. alfcen

    alfcen Well-Known Member Licensed User

    Hello
    The hardware.dll could eventually be enabled to retrieve the Time Zone Information :)
    Thanks
    Robert
     
  2. specci48

    specci48 Well-Known Member Licensed User

  3. alfcen

    alfcen Well-Known Member Licensed User

    That's very kind of you speeci48. Unfortunatelty, I am not in to C and therefore quite helpless at seeing this page :sign0013:
     
  4. specci48

    specci48 Well-Known Member Licensed User

    :signOops:
    I only had a quick look at that page and thought it would describe the registry entry where the time zone is stored on mobile devices...
     
  5. alfcen

    alfcen Well-Known Member Licensed User

    No problem at all, specci48, I know where to find it in the registry, but the data is coded in binary which is alien to me :) at least for now.
    Cheers
    Robert
     
  6. specci48

    specci48 Well-Known Member Licensed User

    ... and where is it stored in the registry?
     
  7. alfcen

    alfcen Well-Known Member Licensed User

    here you go...

    HKEY_LOCAL_MACHINE\Time\TimeZoneInformation

    The value is stored in minutes to account for 'exotic' time zones and is further negative for eastern zones.

    I think the TZ can be extracted with the binary.dll with a few lines of code.

    I did that before in embVB like this :

    homezone = StringToLong(ReadReg(HKEY_LOCAL_MACHINE, "\Time", "TimeZoneInformation")) / 60 * -1

    Private Function StringToLong(strValue As String) As Long
    Dim strTemp As String
    Dim intByte As Long
    On Error Resume Next
    For intByte = 4 To 1 Step -1
    strTemp = strTemp & Hex(AscB(MidB(strValue, intByte, 1)))
    Next intByte
    StringToLong = CLng("&H" & strTemp)
    End Function
     
  8. alfcen

    alfcen Well-Known Member Licensed User

    :sign0013: and on the desktop...

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation
     
  9. alfcen

    alfcen Well-Known Member Licensed User

    Hi again
    Here are the routines.
    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 :)


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

    Sub Globals
    Dim zti(0) As 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\TimeZoneInformation","ActiveTimeBias")
    Return m / 60 * (-1)
    End If
    End Sub

    Sub GetDayLightSavingHour
    'for the desktop only
    Return Reg.GetValue("System\CurrentControlSet\Control\TimeZoneInformation","StandardBias")
    End Sub
     
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