[Mono-bugs] [Bug 332314] DatePart wrong results for WeekOfYear+System+FirstFullWeek on non en-US culture

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Oct 11 10:33:58 EDT 2007


https://bugzilla.novell.com/show_bug.cgi?id=332314#c2


Andy Hume <andyhume32 at yahoo.co.uk> changed:

           What    |Removed                                         |Added
----------------------------------------------------------------------------
                 CC|                                                |andyhume32 at yahoo.co.uk
            Summary|Folow sugestion                                 |DatePart wrong results for
                   |                                                |WeekOfYear+System+FirstFullWeek on non en-US
                   |                                                |culture




--- Comment #2 from Andy Hume <andyhume32 at yahoo.co.uk>  2007-10-11 08:33:57 MST ---
The following gives different results on MSFT vs Mono, for at least fr-Fr and
en-GB.  It is ok for en-US.
[[
  DatePart(DateInterval.WeekOfYear, _
     someDate, 
     FirstDayOfWeek.System, FirstWeekOfYear.FirstFullWeek)
]]

For e.g.
[[
  DatePart(DateInterval.WeekOfYear, _
    new Date(2007, 10, 11), 
    FirstDayOfWeek.System, FirstWeekOfYear.FirstFullWeek)
]]
gives 41 on MSFT but 40 on Mono.  And for 2007-01-05, 1 versus 53.

Main testing on Mono SVN head Win32, but same Mono results seen on 1.2.5 Suse
VM.

For more, diff the output from the following when run on MSFT vs Mono.  Bad
results are seen for en-GB and fr-FR, but not en-US.  So, as Jonathon noted in
the original bug, a problem with FirstDayOfWeek.System when its not Sunday? 
That's the US default IIRC.

[[
Class Foo
    Shared Sub Main
        Console.WriteLine("-----------------------------------------")
        System.Threading.Thread.CurrentThread.CurrentCulture _
            = New System.Globalization.CultureInfo("en-US")
        Console.WriteLine(System.Threading.Thread.CurrentThread.CurrentCulture)
        Console.WriteLine
        RunTests

        Console.WriteLine
        Console.WriteLine
        Console.WriteLine("-----------------------------------------")
        System.Threading.Thread.CurrentThread.CurrentCulture _
            = New System.Globalization.CultureInfo("fr-FR")
        Console.WriteLine(System.Threading.Thread.CurrentThread.CurrentCulture)
        Console.WriteLine
        RunTests

        Console.WriteLine
        Console.WriteLine
        Console.WriteLine("-----------------------------------------")
        System.Threading.Thread.CurrentThread.CurrentCulture _
            = New System.Globalization.CultureInfo("en-GB")
        Console.WriteLine(System.Threading.Thread.CurrentThread.CurrentCulture)
        Console.WriteLine
        RunTests
    End Sub

    Shared Sub RunTests
        WoyAllSettings
        WoyAllSettings(new Date(2007,1,5))
        Woy
        Woy(new Date(2007,1,5))
    End Sub        


    Shared Sub Woy()
        Woy(new Date(2007, 10, 11))
    End Sub

    Shared Sub Woy(date1 As DateTime)
        Console.WriteLine("foo : " & 1.111) ' see comma when fr-FR
        Dim woy As Integer = DatePart(DateInterval.WeekOfYear, _
            date1, _
            FirstDayOfWeek.System, FirstWeekOfYear.FirstFullWeek)
        Console.WriteLine(woy)
        If woy = -1 Then
            Throw New Exception("DatePart returned -1")
        End If
    End Sub


    Shared Sub WoyAllSettings()
        WoyAllSettings(new Date(2007, 10, 11))
    End Sub

    Shared Sub WoyAllSettings(date1 As DateTime)
        For Each fwoy As FirstWeekOfYear in
[Enum].GetValues(GetType(FirstWeekOfYear))
            For Each fdow As FirstDayOfWeek in
[Enum].GetValues(GetType(FirstDayOfWeek))
                Dim week As Integer = DatePart(DateInterval.WeekOfYear, _
                    date1, fdow, fwoy)
                Console.WriteLine("{0,-10} {1,-13}: {2}", _
                    fdow, fwoy, week)
            Next
        Next
    End Sub
End Class
]]

I can't reproduce any -1 result however.  Can you supply any two line program
that does so Eric?


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list