It's always back to ISO-8601 for some reason

by Michael S. Kaplan, published on 2010/10/03 07:01 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2010/10/03/10070787.aspx


It is something I talked about years ago, in my ISO 8601 is asinine blog. And not long after in ISO 8601 redux, which references Shawn's ISO 8601 Week of Year format in Microsoft .Net blog and Isaac's Best Week Ever blog.

Both Shawn and Isaac were trying to work around the fundamental difference between what Microsoft does with its GetLocaleInfo LOCALE_IFIRSTWEEKOFYEAR flag in native code (its DateTimeFormatInfo.CalendarWeekRule in managed code).And how they compare to the ISO 8601 rules, which are used by several different countries.

Unfortunately, the documentation on the Windows/.Net side doesn't help enough to set expectations.

Managed code describes it all as

A CalendarWeekRule value that determines the first calendar week of the year.

Enum member name Description
FirstDay Indicates that the first week of the year starts on the first day of the year and ends before the following designated first day of the week. The value is 0.
FirstFullWeek Indicates that the first week of the year begins on the first occurrence of the designated first day of the week on or after the first day of the year. The value is 1.
FirstFourDayWeek Indicates that the first week of the year is the first week with four or more days before the designated first day of the week. The value is 2.

and native code describes it similarly.

With these descriptions, even with the cool example tables in the CalendarWeekRule enumeration, its official statement "This does not map exactly to ISO 8601", and its direct link to Shawn's blog (proving once and for all that blogs can indeed be treated as official documentation!), it is still way too easy for a person to:

Probably we should just add an actual ISO 8601-compliant locale field, though for whatever reason no one seems eager to do that (we can't change the meaning for the existing property). The workaround is pretty easy (since the MS implementation and the ISO standard aren't that different.

I think we're just going to be stuck with this difference between the two, with people periodically reporting this as a bug....


no comments

go to newer or older post, or back to index or month or day