basic4android and Olson TimeZone

juanmpuertas

Member
Licensed User
Longtime User
Hello. I'm a recent user of basic4android, and my question is if is posible to access to the Olson timezone database.
For example, I have a city and a country from the Olson tz: "Madrid/Spain" and a date and time request: "1941-04-03 14:45" and Olson return: "GMT+01:00". It is this posible with basic4android?
Thanks
 

juanmpuertas

Member
Licensed User
Longtime User
Yes, but getTimeZone android's SDK takes country and time, and return the time zone. This function does not exist in Basic4Android
Thank-you for your help
 
Upvote 0

juanmpuertas

Member
Licensed User
Longtime User
It seems that AHLocale don't work properly. I try a example 120 days before now in Europe/Madrid, when DST is true and "Offset to UTC" should be 2 hours but the function return false and "1 hour".
Thank-you for your help :
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Dim tz As AHTimeZone
   Dim loc As AHLocale
   
   tz.Initialize
   loc.InitializeUS
   
   ' Get a list of all available timezones on the device
   Dim l As List
   l = tz.AvailableIds
   For i = 0 To l.Size - 1
      Log("TimeZoneID: " & l.Get(i))
   Next
   
   tz.Initzialize2("Europe/Madrid") ' <- My example *****
   Log("---")
   Log("Choosen TimezoneID: " & tz.ID)
   tz.ID ="Europe/Madrid"
   Log("TimeZone: " & tz.GetDisplayName(True, tz.STYLE_LONG))
   Log("TimeZone in english: " & tz.GetDisplayName2(True, tz.STYLE_LONG, loc))
   Log("Offset to UTC: " & (tz.getOffset(DateTime.Now-10368000) / DateTime.TicksPerHour) & " hours") ' <- We calculate 120 days before now, when is summer time and DST is true *****
   Log("Is it DST now? " & tz.InDaylightTime(DateTime.Now-10368000))
   
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…