Android Question is date in DST?

ilan

Expert
Licensed User
Longtime User
hi,

is it possible to check if a specific date is in "daylight saving time" for a specific country?

like is the date "12/04/1999" in UK/London summer time or winter time??

there is a list wich each country when they change the clock but is there a simple way to implement it in my code?

https://en.wikipedia.org/wiki/Daylight_saving_time_by_country

like: dim dst as boolean = checkdst("12/04/1999","London")

and get resault of true or false
 

sorex

Expert
Licensed User
Longtime User
you will need to put all that data in your app if you want to cover all countries.

the pain is that some countries used it for some time, then not, then again so you'll have to do multiple checks.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
you will need to put all that data in your app if you want to cover all countries.

the pain is that some countries used it for some time, then not, then again so you'll have to do multiple checks.

i was afraid of that answer, ok then i will need to make a class by myself...

i will not need all countries, only popular ones like belgium ;)
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
@corwin42 could clarify this.

It seems to have dst offsets but I'm not sure if it supports these date ranges that the wiki page has listed.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Upvote 0

ilan

Expert
Licensed User
Longtime User
thanx a lot roy, but the right way to get the country codes is this:

B4X:
    Dim tz As AHTimeZone
    tz.Initialize
    For i = 0 To tz.AvailableIds.Size -1
        Log(tz.AvailableIds.get(i))
    Next

now i can get what i asked for like this:

B4X:
Sub chckifwintertime(date As Long, land As String) As Int
   
    'land = "Asia/Jerusalem"
   
    Dim dstint As Int = 0
    Dim tz As AHTimeZone
    tz.Initialize2(land)
    Log("dst: " & tz.InDaylightTime(date))   
    If tz.InDaylightTime(date) Then dstint = 0 Else dstint = -1
   
    Return dstint
End Sub

thank you very much! :)
 
Upvote 0
Top