Bug in TimeZone.CurrentTimeZone.IsDaylightSavingTime RRS feed

  • Question

  • I believe that I have found a boundary error bug in the TimeZone.CurrentTimeZone.IsDaylightSavingTime method.

    In the middle of the day on November 1, 2020, a call to TimeZone.CurrentTimeZone.IsDaylightSavingTime returns "True" even though DST ended at 2am on that date, & the correct value is "False".

    The following code returns the wrong value:        

               If TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now.Date) Then
                    Return TimeZone.CurrentTimeZone.DaylightName
                    Return TimeZone.CurrentTimeZone.StandardName
                End If

    However, the following code returns the correct value:

                Dim dlt As DaylightTime = TimeZone.CurrentTimeZone.GetDaylightChanges(Now.Year)
                If Now > dlt.Start And Now < dlt.End Then
                    Return TimeZone.CurrentTimeZone.DaylightName
                    Return TimeZone.CurrentTimeZone.StandardName
                End If

    Sunday, November 1, 2020 4:25 PM

All replies

  • Hello,

    If you believe this is a bug than use the feedback button in the upper right corner of Visual Studio to report it as Microsoft will see and verify if or if not a bug and if there are plans to fix it.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    My GitHub code samples
    GitHub page

    Sunday, November 1, 2020 10:26 PM
  • Hi Ray K9DUR,

    Thank you for posting here.

    You can also consider reporting your problem on 'Developer Community' forum

    Best Regards,

    Xingyu Zhao

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, November 2, 2020 2:51 AM