Home All Groups Group Topic Archive Search About

IsDayLightSavingTime doesn't work for 2007 and beyond

Author
6 Apr 2006 10:57 PM
vCharley Lee
Is this going to be patched?  I ran this code and it fails to report the
correct state of Daylight Savings Time in Pacific Time zone.  March 12, 2007
should be DST.

Thanks,

Charley

' Example of the TimeZone.IsDaylightSavingTime( DateTime ),
' TimeZone.IsDaylightSavingTime( DateTime, DaylightTime ), and
' TimeZone.ToUniversalTime( DateTime ) methods.
Imports System
Imports System.Globalization
Imports Microsoft.VisualBasic

Module DaylightTimeDemo

    Sub Main()

        Const headFmt As String = "{0,-22}{1,-10}{2,-10}{3,-10}{4}"

        ' Get the local time zone and a base local time.
        Dim localZone As TimeZone = TimeZone.CurrentTimeZone
        Dim localTime As DateTime = New DateTime(2007, 3, 12)

        Console.WriteLine("This example of " & vbCrLf & _
            "   TimeZone.IsDaylightSavingTime( DateTime ), " & _
            vbCrLf & "   TimeZone.IsDaylightSavingTime( " & _
            "DateTime, DaylightTime ), and " & vbCrLf & _
            "   TimeZone.ToUniversalTime( DateTime )" & vbCrLf & _
            "generates the following output, which varies " & _
            "depending on the " & vbCrLf & "time zone in which " & _
            "it is run." & vbCrLf)
        Console.WriteLine("The example creates " & _
            "several local times and the corresponding " & vbCrLf & _
            "Coordinated Universal Times (UTC) and shows if " & _
            "they occur in " & vbCrLf & "daylight saving time " & _
            "(DST), both for specified years and for " & vbCrLf & _
            "any year." & vbCrLf)
        Console.WriteLine("Local time: {0}" & vbCrLf, _
            localZone.StandardName)

        Console.WriteLine(headFmt, "Local Date and Time", _
            "2001 DST?", "2002 DST?", "Any DST?", "Corresponding UTC")
        Console.WriteLine(headFmt, "-------------------", _
            "---------", "---------", "--------", "-----------------")

        ' Create DaylightTime objects for specific years.
        Dim daylight2001 As DaylightTime = _
            localZone.GetDaylightChanges(2001)
        Dim daylight2002 As DaylightTime = _
            localZone.GetDaylightChanges(2002)

        ' Generate several local times.
        Dim loopX As Integer
        For loopX = 0 To 10

            ' Calculate the corresponding UTC.
            Dim utcTime As DateTime = _
                localZone.ToUniversalTime(localTime)

            ' Show if dates and times occur in daylight saving
            ' time, for specified years and for any year.
            Console.WriteLine("{0,-22:yyyy-MM-dd HH:mm}" & _
                "{1,-10}{2,-10}{3,-10}{4:yyyy-MM-dd HH:mm}", _
                localTime, _
                TimeZone.IsDaylightSavingTime( _
                    localTime, daylight2001), _
                TimeZone.IsDaylightSavingTime( _
                    localTime, daylight2002), _
                localZone.IsDaylightSavingTime(localTime), _
                utcTime)

            ' Advance to another local time.
            localTime = localTime.AddDays(109.1)
        Next loopX
        Threading.Thread.Sleep(60000)
    End Sub
End Module

' This example of
'    TimeZone.IsDaylightSavingTime( DateTime ),
'    TimeZone.IsDaylightSavingTime( DateTime, DaylightTime ), and
'    TimeZone.ToUniversalTime( DateTime )
' generates the following output, which varies depending on the
' time zone in which it is run.
'
' The example creates several local times and the corresponding
' Coordinated Universal Times (UTC) and shows if they occur in
' daylight saving time (DST), both for specified years and for
' any year.
'
' Local time: Pacific Standard Time
'
' Local Date and Time   2001 DST? 2002 DST? Any DST?  Corresponding UTC
' -------------------   --------- --------- --------  -----------------
' 2001-01-01 00:00      False     False     False     2001-01-01 08:00
' 2001-04-20 02:24      True      False     True      2001-04-20 09:24
' 2001-08-07 04:48      True      False     True      2001-08-07 11:48
' 2001-11-24 07:12      False     False     False     2001-11-24 15:12
' 2002-03-13 09:36      False     False     False     2002-03-13 17:36
' 2002-06-30 12:00      False     True      True      2002-06-30 19:00
' 2002-10-17 14:24      False     True      True      2002-10-17 21:24
' 2003-02-03 16:48      False     False     False     2003-02-04 00:48
' 2003-05-23 19:12      False     False     True      2003-05-24 02:12
' 2003-09-09 21:36      False     False     True      2003-09-10 04:36
' 2003-12-28 00:00      False     False     False     2003-12-28 08:00

Author
8 Apr 2006 10:22 PM
Michael D. Ober
This is a change to the US DST laws.  MS (and just about every other OS and
tool vendor) will need to issue several patches for this one.

Mike Ober.

Show quote
"vCharley Lee" <cs***@russell.com> wrote in message
news:%23N%23gw1cWGHA.4324@TK2MSFTNGP03.phx.gbl...
> Is this going to be patched?  I ran this code and it fails to report the
> correct state of Daylight Savings Time in Pacific Time zone.  March 12,
2007
> should be DST.
>
> Thanks,
>
> Charley
>
> ' Example of the TimeZone.IsDaylightSavingTime( DateTime ),
> ' TimeZone.IsDaylightSavingTime( DateTime, DaylightTime ), and
> ' TimeZone.ToUniversalTime( DateTime ) methods.
> Imports System
> Imports System.Globalization
> Imports Microsoft.VisualBasic
>
> Module DaylightTimeDemo
>
>     Sub Main()
>
>         Const headFmt As String = "{0,-22}{1,-10}{2,-10}{3,-10}{4}"
>
>         ' Get the local time zone and a base local time.
>         Dim localZone As TimeZone = TimeZone.CurrentTimeZone
>         Dim localTime As DateTime = New DateTime(2007, 3, 12)
>
>         Console.WriteLine("This example of " & vbCrLf & _
>             "   TimeZone.IsDaylightSavingTime( DateTime ), " & _
>             vbCrLf & "   TimeZone.IsDaylightSavingTime( " & _
>             "DateTime, DaylightTime ), and " & vbCrLf & _
>             "   TimeZone.ToUniversalTime( DateTime )" & vbCrLf & _
>             "generates the following output, which varies " & _
>             "depending on the " & vbCrLf & "time zone in which " & _
>             "it is run." & vbCrLf)
>         Console.WriteLine("The example creates " & _
>             "several local times and the corresponding " & vbCrLf & _
>             "Coordinated Universal Times (UTC) and shows if " & _
>             "they occur in " & vbCrLf & "daylight saving time " & _
>             "(DST), both for specified years and for " & vbCrLf & _
>             "any year." & vbCrLf)
>         Console.WriteLine("Local time: {0}" & vbCrLf, _
>             localZone.StandardName)
>
>         Console.WriteLine(headFmt, "Local Date and Time", _
>             "2001 DST?", "2002 DST?", "Any DST?", "Corresponding UTC")
>         Console.WriteLine(headFmt, "-------------------", _
>             "---------", "---------", "--------", "-----------------")
>
>         ' Create DaylightTime objects for specific years.
>         Dim daylight2001 As DaylightTime = _
>             localZone.GetDaylightChanges(2001)
>         Dim daylight2002 As DaylightTime = _
>             localZone.GetDaylightChanges(2002)
>
>         ' Generate several local times.
>         Dim loopX As Integer
>         For loopX = 0 To 10
>
>             ' Calculate the corresponding UTC.
>             Dim utcTime As DateTime = _
>                 localZone.ToUniversalTime(localTime)
>
>             ' Show if dates and times occur in daylight saving
>             ' time, for specified years and for any year.
>             Console.WriteLine("{0,-22:yyyy-MM-dd HH:mm}" & _
>                 "{1,-10}{2,-10}{3,-10}{4:yyyy-MM-dd HH:mm}", _
>                 localTime, _
>                 TimeZone.IsDaylightSavingTime( _
>                     localTime, daylight2001), _
>                 TimeZone.IsDaylightSavingTime( _
>                     localTime, daylight2002), _
>                 localZone.IsDaylightSavingTime(localTime), _
>                 utcTime)
>
>             ' Advance to another local time.
>             localTime = localTime.AddDays(109.1)
>         Next loopX
>         Threading.Thread.Sleep(60000)
>     End Sub
> End Module
>
> ' This example of
> '    TimeZone.IsDaylightSavingTime( DateTime ),
> '    TimeZone.IsDaylightSavingTime( DateTime, DaylightTime ), and
> '    TimeZone.ToUniversalTime( DateTime )
> ' generates the following output, which varies depending on the
> ' time zone in which it is run.
> '
> ' The example creates several local times and the corresponding
> ' Coordinated Universal Times (UTC) and shows if they occur in
> ' daylight saving time (DST), both for specified years and for
> ' any year.
> '
> ' Local time: Pacific Standard Time
> '
> ' Local Date and Time   2001 DST? 2002 DST? Any DST?  Corresponding UTC
> ' -------------------   --------- --------- --------  -----------------
> ' 2001-01-01 00:00      False     False     False     2001-01-01 08:00
> ' 2001-04-20 02:24      True      False     True      2001-04-20 09:24
> ' 2001-08-07 04:48      True      False     True      2001-08-07 11:48
> ' 2001-11-24 07:12      False     False     False     2001-11-24 15:12
> ' 2002-03-13 09:36      False     False     False     2002-03-13 17:36
> ' 2002-06-30 12:00      False     True      True      2002-06-30 19:00
> ' 2002-10-17 14:24      False     True      True      2002-10-17 21:24
> ' 2003-02-03 16:48      False     False     False     2003-02-04 00:48
> ' 2003-05-23 19:12      False     False     True      2003-05-24 02:12
> ' 2003-09-09 21:36      False     False     True      2003-09-10 04:36
> ' 2003-12-28 00:00      False     False     False     2003-12-28 08:00
>
>
>
Author
10 Apr 2006 5:32 PM
vCharley Lee
So does anyone know how this will be distributed?  Simply a hotfix/patch or
in a service pack?  Is there an official response from MS?

Thanks,

Charley Lee
Russell Investment Group
Senior Software Developer

Show quote
"Michael D. Ober" <ober***@.alum.mit.edu.nospam> wrote in message
news:CIWZf.1600$BS2.999@newsread1.news.pas.earthlink.net...
> This is a change to the US DST laws.  MS (and just about every other OS
> and
> tool vendor) will need to issue several patches for this one.
>
> Mike Ober.
>
> "vCharley Lee" <cs***@russell.com> wrote in message
> news:%23N%23gw1cWGHA.4324@TK2MSFTNGP03.phx.gbl...
>> Is this going to be patched?  I ran this code and it fails to report the
>> correct state of Daylight Savings Time in Pacific Time zone.  March 12,
> 2007
>> should be DST.
>>
>> Thanks,
>>
>> Charley
>>
>> ' Example of the TimeZone.IsDaylightSavingTime( DateTime ),
>> ' TimeZone.IsDaylightSavingTime( DateTime, DaylightTime ), and
>> ' TimeZone.ToUniversalTime( DateTime ) methods.
>> Imports System
>> Imports System.Globalization
>> Imports Microsoft.VisualBasic
>>
>> Module DaylightTimeDemo
>>
>>     Sub Main()
>>
>>         Const headFmt As String = "{0,-22}{1,-10}{2,-10}{3,-10}{4}"
>>
>>         ' Get the local time zone and a base local time.
>>         Dim localZone As TimeZone = TimeZone.CurrentTimeZone
>>         Dim localTime As DateTime = New DateTime(2007, 3, 12)
>>
>>         Console.WriteLine("This example of " & vbCrLf & _
>>             "   TimeZone.IsDaylightSavingTime( DateTime ), " & _
>>             vbCrLf & "   TimeZone.IsDaylightSavingTime( " & _
>>             "DateTime, DaylightTime ), and " & vbCrLf & _
>>             "   TimeZone.ToUniversalTime( DateTime )" & vbCrLf & _
>>             "generates the following output, which varies " & _
>>             "depending on the " & vbCrLf & "time zone in which " & _
>>             "it is run." & vbCrLf)
>>         Console.WriteLine("The example creates " & _
>>             "several local times and the corresponding " & vbCrLf & _
>>             "Coordinated Universal Times (UTC) and shows if " & _
>>             "they occur in " & vbCrLf & "daylight saving time " & _
>>             "(DST), both for specified years and for " & vbCrLf & _
>>             "any year." & vbCrLf)
>>         Console.WriteLine("Local time: {0}" & vbCrLf, _
>>             localZone.StandardName)
>>
>>         Console.WriteLine(headFmt, "Local Date and Time", _
>>             "2001 DST?", "2002 DST?", "Any DST?", "Corresponding UTC")
>>         Console.WriteLine(headFmt, "-------------------", _
>>             "---------", "---------", "--------", "-----------------")
>>
>>         ' Create DaylightTime objects for specific years.
>>         Dim daylight2001 As DaylightTime = _
>>             localZone.GetDaylightChanges(2001)
>>         Dim daylight2002 As DaylightTime = _
>>             localZone.GetDaylightChanges(2002)
>>
>>         ' Generate several local times.
>>         Dim loopX As Integer
>>         For loopX = 0 To 10
>>
>>             ' Calculate the corresponding UTC.
>>             Dim utcTime As DateTime = _
>>                 localZone.ToUniversalTime(localTime)
>>
>>             ' Show if dates and times occur in daylight saving
>>             ' time, for specified years and for any year.
>>             Console.WriteLine("{0,-22:yyyy-MM-dd HH:mm}" & _
>>                 "{1,-10}{2,-10}{3,-10}{4:yyyy-MM-dd HH:mm}", _
>>                 localTime, _
>>                 TimeZone.IsDaylightSavingTime( _
>>                     localTime, daylight2001), _
>>                 TimeZone.IsDaylightSavingTime( _
>>                     localTime, daylight2002), _
>>                 localZone.IsDaylightSavingTime(localTime), _
>>                 utcTime)
>>
>>             ' Advance to another local time.
>>             localTime = localTime.AddDays(109.1)
>>         Next loopX
>>         Threading.Thread.Sleep(60000)
>>     End Sub
>> End Module
>>
>> ' This example of
>> '    TimeZone.IsDaylightSavingTime( DateTime ),
>> '    TimeZone.IsDaylightSavingTime( DateTime, DaylightTime ), and
>> '    TimeZone.ToUniversalTime( DateTime )
>> ' generates the following output, which varies depending on the
>> ' time zone in which it is run.
>> '
>> ' The example creates several local times and the corresponding
>> ' Coordinated Universal Times (UTC) and shows if they occur in
>> ' daylight saving time (DST), both for specified years and for
>> ' any year.
>> '
>> ' Local time: Pacific Standard Time
>> '
>> ' Local Date and Time   2001 DST? 2002 DST? Any DST?  Corresponding UTC
>> ' -------------------   --------- --------- --------  -----------------
>> ' 2001-01-01 00:00      False     False     False     2001-01-01 08:00
>> ' 2001-04-20 02:24      True      False     True      2001-04-20 09:24
>> ' 2001-08-07 04:48      True      False     True      2001-08-07 11:48
>> ' 2001-11-24 07:12      False     False     False     2001-11-24 15:12
>> ' 2002-03-13 09:36      False     False     False     2002-03-13 17:36
>> ' 2002-06-30 12:00      False     True      True      2002-06-30 19:00
>> ' 2002-10-17 14:24      False     True      True      2002-10-17 21:24
>> ' 2003-02-03 16:48      False     False     False     2003-02-04 00:48
>> ' 2003-05-23 19:12      False     False     True      2003-05-24 02:12
>> ' 2003-09-09 21:36      False     False     True      2003-09-10 04:36
>> ' 2003-12-28 00:00      False     False     False     2003-12-28 08:00
>>
>>
>>
>
>
>
Author
10 Apr 2006 6:58 PM
Michael D. Ober
Probably on Patch Tuesday.  MS had to send out a similar patch for Australia
this year.

Mike.

Show quote
"vCharley Lee" <cs***@russell.com> wrote in message
news:ukIj9SMXGHA.1084@TK2MSFTNGP04.phx.gbl...
>
> So does anyone know how this will be distributed?  Simply a hotfix/patch
or
> in a service pack?  Is there an official response from MS?
>
> Thanks,
>
> Charley Lee
> Russell Investment Group
> Senior Software Developer
>
> "Michael D. Ober" <ober***@.alum.mit.edu.nospam> wrote in message
> news:CIWZf.1600$BS2.999@newsread1.news.pas.earthlink.net...
> > This is a change to the US DST laws.  MS (and just about every other OS
> > and
> > tool vendor) will need to issue several patches for this one.
> >
> > Mike Ober.
> >
> > "vCharley Lee" <cs***@russell.com> wrote in message
> > news:%23N%23gw1cWGHA.4324@TK2MSFTNGP03.phx.gbl...
> >> Is this going to be patched?  I ran this code and it fails to report
the
> >> correct state of Daylight Savings Time in Pacific Time zone.  March 12,
> > 2007
> >> should be DST.
> >>
> >> Thanks,
> >>
> >> Charley
> >>
> >> ' Example of the TimeZone.IsDaylightSavingTime( DateTime ),
> >> ' TimeZone.IsDaylightSavingTime( DateTime, DaylightTime ), and
> >> ' TimeZone.ToUniversalTime( DateTime ) methods.
> >> Imports System
> >> Imports System.Globalization
> >> Imports Microsoft.VisualBasic
> >>
> >> Module DaylightTimeDemo
> >>
> >>     Sub Main()
> >>
> >>         Const headFmt As String = "{0,-22}{1,-10}{2,-10}{3,-10}{4}"
> >>
> >>         ' Get the local time zone and a base local time.
> >>         Dim localZone As TimeZone = TimeZone.CurrentTimeZone
> >>         Dim localTime As DateTime = New DateTime(2007, 3, 12)
> >>
> >>         Console.WriteLine("This example of " & vbCrLf & _
> >>             "   TimeZone.IsDaylightSavingTime( DateTime ), " & _
> >>             vbCrLf & "   TimeZone.IsDaylightSavingTime( " & _
> >>             "DateTime, DaylightTime ), and " & vbCrLf & _
> >>             "   TimeZone.ToUniversalTime( DateTime )" & vbCrLf & _
> >>             "generates the following output, which varies " & _
> >>             "depending on the " & vbCrLf & "time zone in which " & _
> >>             "it is run." & vbCrLf)
> >>         Console.WriteLine("The example creates " & _
> >>             "several local times and the corresponding " & vbCrLf & _
> >>             "Coordinated Universal Times (UTC) and shows if " & _
> >>             "they occur in " & vbCrLf & "daylight saving time " & _
> >>             "(DST), both for specified years and for " & vbCrLf & _
> >>             "any year." & vbCrLf)
> >>         Console.WriteLine("Local time: {0}" & vbCrLf, _
> >>             localZone.StandardName)
> >>
> >>         Console.WriteLine(headFmt, "Local Date and Time", _
> >>             "2001 DST?", "2002 DST?", "Any DST?", "Corresponding UTC")
> >>         Console.WriteLine(headFmt, "-------------------", _
> >>             "---------", "---------", "--------", "-----------------")
> >>
> >>         ' Create DaylightTime objects for specific years.
> >>         Dim daylight2001 As DaylightTime = _
> >>             localZone.GetDaylightChanges(2001)
> >>         Dim daylight2002 As DaylightTime = _
> >>             localZone.GetDaylightChanges(2002)
> >>
> >>         ' Generate several local times.
> >>         Dim loopX As Integer
> >>         For loopX = 0 To 10
> >>
> >>             ' Calculate the corresponding UTC.
> >>             Dim utcTime As DateTime = _
> >>                 localZone.ToUniversalTime(localTime)
> >>
> >>             ' Show if dates and times occur in daylight saving
> >>             ' time, for specified years and for any year.
> >>             Console.WriteLine("{0,-22:yyyy-MM-dd HH:mm}" & _
> >>                 "{1,-10}{2,-10}{3,-10}{4:yyyy-MM-dd HH:mm}", _
> >>                 localTime, _
> >>                 TimeZone.IsDaylightSavingTime( _
> >>                     localTime, daylight2001), _
> >>                 TimeZone.IsDaylightSavingTime( _
> >>                     localTime, daylight2002), _
> >>                 localZone.IsDaylightSavingTime(localTime), _
> >>                 utcTime)
> >>
> >>             ' Advance to another local time.
> >>             localTime = localTime.AddDays(109.1)
> >>         Next loopX
> >>         Threading.Thread.Sleep(60000)
> >>     End Sub
> >> End Module
> >>
> >> ' This example of
> >> '    TimeZone.IsDaylightSavingTime( DateTime ),
> >> '    TimeZone.IsDaylightSavingTime( DateTime, DaylightTime ), and
> >> '    TimeZone.ToUniversalTime( DateTime )
> >> ' generates the following output, which varies depending on the
> >> ' time zone in which it is run.
> >> '
> >> ' The example creates several local times and the corresponding
> >> ' Coordinated Universal Times (UTC) and shows if they occur in
> >> ' daylight saving time (DST), both for specified years and for
> >> ' any year.
> >> '
> >> ' Local time: Pacific Standard Time
> >> '
> >> ' Local Date and Time   2001 DST? 2002 DST? Any DST?  Corresponding UTC
> >> ' -------------------   --------- --------- --------  -----------------
> >> ' 2001-01-01 00:00      False     False     False     2001-01-01 08:00
> >> ' 2001-04-20 02:24      True      False     True      2001-04-20 09:24
> >> ' 2001-08-07 04:48      True      False     True      2001-08-07 11:48
> >> ' 2001-11-24 07:12      False     False     False     2001-11-24 15:12
> >> ' 2002-03-13 09:36      False     False     False     2002-03-13 17:36
> >> ' 2002-06-30 12:00      False     True      True      2002-06-30 19:00
> >> ' 2002-10-17 14:24      False     True      True      2002-10-17 21:24
> >> ' 2003-02-03 16:48      False     False     False     2003-02-04 00:48
> >> ' 2003-05-23 19:12      False     False     True      2003-05-24 02:12
> >> ' 2003-09-09 21:36      False     False     True      2003-09-10 04:36
> >> ' 2003-12-28 00:00      False     False     False     2003-12-28 08:00
> >>
> >>
> >>
> >
> >
> >
>
>
>

AddThis Social Bookmark Button