GetTimeZone

alfcen

Well-Known Member
Licensed User
Longtime 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)

B4X:
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\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
 

alfcen

Well-Known Member
Licensed User
Longtime User
Hi Dimitris
Thanks a lot for testing and your feedback. Good knowing everything works on various platforms.
Cheers
Robert
 

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:

alfcen

Well-Known Member
Licensed User
Longtime 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.
 
Top