Skip to content

Calender.GetWeekOfYear is not compatible with ISO 8601 and date Unix utility #25762

@iSazonov

Description

@iSazonov

System.Threading.Thread.CurrentThread.CurrentCulture.Calendar.GetWeekOfYear() return values that are not compatible with ISO 8601 and date Unix utility in some edge cases.

ISO related link

The issue was discovered in PowerShell repo PowerShell/PowerShell#6542 (You should use the build if you want tests with PowerShell Core Get-Date cmdlet).

If it is on a Sunday, it is part of week 52 of the previous year.

#'2017-01-01' is 'Sunday, January 1, 2017 12:00:00 AM'
date -d 2017-01-01 +%V #return 52 - right
Get-date 2017-01-01 -UFormat "%V" #return 1 - bug

If 31 December is on a Monday, Tuesday or Wednesday, it is in week 01 of the next year.

#'2007-12-31' is 'Monday, December 31, 2007 12:00:00 AM'
date -d 2011-12-31 +%V #return 01 - right
Get-date 2011-12-31 -UFormat "%V" #return 53 - bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.GlobalizationquestionAnswer questions and provide assistance, not an issue with source code or documentation.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions