View Single Post
  #9 (permalink)  
Old 09-19-2009, 08:50 AM
mjcoon mjcoon is offline
Basic4ppc Expert
 
Join Date: May 2008
Location: Berkshire, UK
Posts: 810
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by alfcen View Post
Ciao Filippo,
Execellent! Awesome!

Thanks to your DLL, I can set the clock with GPS date and time.
Here is the source for everybody. Perhaps someone can shorten it

Code:
...

Sub GetTimeZone
  
Dim m, i, b
  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
    m = 
bit.HexToDec(m) / 60 * (-1)
  
Else
    m = Reg.GetValue(
"System\CurrentControlSet\Control\TimeZoneInformation","ActiveTimeBias")
    m = m  / 
60 * (-1)
  
End If
  
If m > 0 Then m = "+" & m
  
Return m    
End Sub
I guess all that stuff with DecToHex and HexToDec is just to convert 4 bytes to a 32-bit integer. Which could be done with some *256 or neatly with the ByteConverter DLL using Int32FromBytes().

But reading the registry item separately on my PDA gives four zeroes (but lots of other following bytes; goodness knows what they mean!). This is fair enough since I am in Zulu time zone. But I am also in daylight saving time, so where would that other hour correction come from?

Mike.
Reply With Quote