Hi all.
I have a problem with checking if DST has started.
Here is my code - this is just an example
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
My app checks if DST has started and shows a message to the user that he needs to wait for 1 hour until the device will switch to either summer or winter time. I've got a call from one of the user that he got this message on the night from 3/14/2021 to 3/15/2021. It was weird because DST night in the USA was 24 hours earlier (at 1:30 AM 03/14/2021).
I checked my code and I found that offsets the night before the DST are the same (Offset1=-5 and Offset2=-5) for dates 03/12/2021 and 03/13/2021. It's correct
I expected that offsets will be different for dates 03/13/2021 and 03/14/2021. But they are the same (Offset1=-5 and Offset2=-5). It's weird - we switched to the DST on 03/14/2021.
And finally offsets are different for 03/14/2021 and 03/15/2021 - Offset1=-5 and Offset2=-4.
Here is a log
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
So my question is - what am I doing wrong?
I attached my small project.
			
			I have a problem with checking if DST has started.
Here is my code - this is just an example
			
				B4X:
			
		
		
		private Sub CheckIsDST
  
    Try
      
        Dim Offset1 As Double,Offset2 As Double
        Dim Date1 As String,Date2 As String
      
        Date1="03/12/2021"
        Date2="03/13/2021"
      
        Offset1=DateTime.GetTimeZoneOffsetAt(DateTime.DateParse(Date1))
        Offset2=DateTime.GetTimeZoneOffsetAt(DateTime.DateParse(Date2))
      
        Log("Date1=" & Date1 &  TAB &  "Date2=" & Date2 & TAB &  "Offset1=" & Offset1 & TAB & "Offset2=" & Offset2)
      
        'DST started on 03/14/2021 at 1:30 AM so I expected that offset 1 and offset 2 will be different             
        Date1="03/13/2021"
        Date2="03/14/2021"
      
        Offset1=DateTime.GetTimeZoneOffsetAt(DateTime.DateParse(Date1))
        Offset2=DateTime.GetTimeZoneOffsetAt(DateTime.DateParse(Date2))
      
        Log("Date1=" & Date1 &  TAB &  "Date2=" & Date2 & TAB &  "Offset1=" & Offset1 & TAB & "Offset2=" & Offset2 & TAB & "DST started")
      
        Date1="03/14/2021"
        Date2="03/15/2021"
        'Why it happens here - 24 hours later?
        Offset1=DateTime.GetTimeZoneOffsetAt(DateTime.DateParse(Date1))
        Offset2=DateTime.GetTimeZoneOffsetAt(DateTime.DateParse(Date2))
      
        Log("Date1=" & Date1 &  TAB &  "Date2=" & Date2 & TAB &  "Offset1=" & Offset1 & TAB & "Offset2=" & Offset2)
      
        Date1="03/15/2021"
        Date2="03/16/2021"
      
        Offset1=DateTime.GetTimeZoneOffsetAt(DateTime.DateParse(Date1))
        Offset2=DateTime.GetTimeZoneOffsetAt(DateTime.DateParse(Date2))
      
        Log("Date1=" & Date1 &  TAB &  "Date2=" & Date2 & TAB &  "Offset1=" & Offset1 & TAB & "Offset2=" & Offset2)
      
    Catch
        Log("CheckIsDST " & LastException)     
    End Try
  
End Sub
	My app checks if DST has started and shows a message to the user that he needs to wait for 1 hour until the device will switch to either summer or winter time. I've got a call from one of the user that he got this message on the night from 3/14/2021 to 3/15/2021. It was weird because DST night in the USA was 24 hours earlier (at 1:30 AM 03/14/2021).
I checked my code and I found that offsets the night before the DST are the same (Offset1=-5 and Offset2=-5) for dates 03/12/2021 and 03/13/2021. It's correct
I expected that offsets will be different for dates 03/13/2021 and 03/14/2021. But they are the same (Offset1=-5 and Offset2=-5). It's weird - we switched to the DST on 03/14/2021.
And finally offsets are different for 03/14/2021 and 03/15/2021 - Offset1=-5 and Offset2=-4.
Here is a log
			
				B4X:
			
		
		
		--------- beginning of system
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Activity (main) Create, isFirst = true **
Date1=03/12/2021    Date2=03/13/2021    Offset1=-5    Offset2=-5
Date1=03/13/2021    Date2=03/14/2021    Offset1=-5    Offset2=-5    DST started
Date1=03/14/2021    Date2=03/15/2021    Offset1=-5    Offset2=-4
Date1=03/15/2021    Date2=03/16/2021    Offset1=-4    Offset2=-4
** Activity (main) Resume **
	So my question is - what am I doing wrong?
I attached my small project.