ISO 8601 is asinine

Sorting it all Out
Michael Kaplan's random stuff of dubious value
Be sure to read the disclaimer here first!

ISO 8601 is asinine

  • Comments 41

From the I Can't Believe Michael Said That Out Loud files....

A few years ago, Aimee Mann was talking about the song Long Shot from her album I'm With Stupid:

There are at least four songs on it that I wrote for myself and said, 'It's fine. This will never get on the album anyway.' 'Long Shot' was one of those and lo and behold, it's the single. You don't put words like 'You fucked it up' into a song if you want it to be a single. But that line had to be there; it had to have that sound of colloquial dismissiveness.

So perhaps I should not have ISO 8601 is asinine as the title of my post. But that title has to be there; I had to have that sound of not entirely colloquial dismissiveness? :-)

(I also do really like Long Shot by the way, though only live -- mostly because when it is performed live there is a very awesome Julian Coryell electric guitar solo at the end which is just a serious rocking-out fest that you can close a show with. An entirely irrelevant and off-topic point but it must be said because Julian is an awesome guitarist!)

I'll put up the Wikipedia link on ISO 8601, although who knows what that will say tomorrow. :-)

But anyway, I was reading the other day in the SQL Server 2005: CLR Integration blog, in Isaac K. Kunen's post Best Week Ever. Isaac explained one of examples of a difference between what SQL Server 2005 does and what ISO8601 says:

Unfortunately, SQL Server defines the first week of the year as the week in which 1 January lies.  (Some of us would argue that this makes more sense, but ISO 8601 says what ISO 8601 says.)

What's a poor database developer to do?  Wait until the next release of SQL Server?

Why do we have this preconeived notion that if it is an ISO standard, it is better? There are lots of times that this is not the case, and this standard especially is one of them.

Why? I'll tell you. Because what it tries to do as a standard is to regularize many aspects of dates/time handling that actually vary depending on the location in which you sit. That is why the GetLocaleInfo function has an LCTYPE representing the first week of the year (LOCALE_IFIRSTWEEKOFYEAR) with one of the following entries in it:

Value Meaning
0 Week containing 1/1 is the first week of that year.
1 First full week following 1/1 is the first week of that year.
2 First week containing at least four days is the first week of that year.

and another LCTYPE representing the first day of the week (LOCALE_IFIRSTDAYOFWEEK) with the following entries in it:

Value Meaning
0 LOCALE_SDAYNAME1 (Monday)
1 LOCALE_SDAYNAME2 (Tuesday)
2 LOCALE_SDAYNAME3 (Wednesday)
3 LOCALE_SDAYNAME4 (Thursday)
4 LOCALE_SDAYNAME5 (Friday)
5 LOCALE_SDAYNAME6 (Saturday)
6 LOCALE_SDAYNAME7 (Sunday)

The date behind these same two LCTYPE values are the ones used for DateTimeFormatInfo's FirstDayOfWeek and CalendarWeekRule properties.

The simple issue is one of respect -- respecting the fact that in different places there are different preferences. How can someone ignore those preferences?

One could argue that the problem is not with the international standard that steamrolls over those preferences, it is with the products that it used where it should not be. But that ignores the fact that people like to follow international standards, even in cases such as this one where it makes them look like lemmings going right off the cliff of common sense.

Off the top of my head I cannot recall if SQL Server follows a LOCALE_IFIRSTWEEKOFYEAR-esque solution or is hardcoded to use the '0' entry in our locale data -- so I am not sure if they need a little work here, too. I'll give it a try at some point to find out for sure, if someone else does not report back on this point first! :-)

Now there are other examples in ISO 8601 that do the same sort of regularization of something that is truly different in different locales. And the W3C uses it to try to reduce complexity and errors which is a great goal unless it causes a de facto cultural imperialism of sorts by forcing people to change the way they think about software.

I may be inviting with my provocative viewpoint a whole host of fans of the ISO 8601 standard to complain about why it is so crucial that this standard exist, so let me mention ahead of time where my biggest problem is with it -- that it tries to be human readable in so many cases. If it is human readable than it ought to prefer user preferences for locales. If ISO 8601:

  • only tried to define a binary standard, and
  • removed all of the pieces that did not forward the binary standard, and
  • did not struggle to point out those various attempts at better human readability, and
  • if it strongly discouraged people from plugging in the various pieces in the way that Isaac was implying SQL Server ought to in a future version, and
  • if it worked harder to point out how wrong it is to misuse it in so many of these other contexts

then perhaps I would not mind it as much. Then I would just focus on the people misusing it.

But in its current form, it is just too easy to misuse in software products in the name of conformance to standards. Even when doing so makes the standard look bad, and the software products look worse....

 

This post brought to you by "Ƨ" (U+01a7, a.k.a. LATIN CAPITAL LETTER TONE TWO)

Comment on the blather
Leave a Comment
  • Please add 5 and 4 and type the answer here:
  • Post
Blog - Comment List
  • This documentation ought to be updated:

    "First week containing at least four days is the first week of that year."

    _Every_ week contains at least four days. Seven, to be exact.

    :-)

    Primoz
  • In this case as in most others ONE standard is better than hundreds of conflicting standards which might as well be no standard at all.

    It's too easy to decide "this is a locale issue" and not actually solve the problem. That's what the Excel team did in many places for example, and the result is that an arbitrary Excel spreadsheet is meaningful ONLY in the context of the exact same Windows version and configuration which created it.

    The W3C can't say (as Microsoft does) "Oh, well, you just need to ensure that every computer which needs access to this document is identically configured", because they set standards for a genuinely global, world wide web. So here's a standard for representing time that's international.

    Although it's briefly fun to characterise all attempts at harmonisation as "cultural imperialism" it doesn't really make any sense in the context of international standards bodies. Whose culture is being imposed on whom? Am I being Japanised by using Year-Month-Day order? Or is it a conspiracy by the West to impose the latin letter T on the millions of Chinese? Isn't it possible that people from around the world agreed on something, and that defying it is rather perverse?
  • Nick -- The issue mentioned here (and many others in ISO 8601) *are* locale specific and there is no requirement to fold everything together to force everyone to use one nmber to answers the question of what is the first week of the year.

    I am a huge fan of standards when they make sense, but I am a huger fan of appropriate standards usage and having standards written to discourage improper usage -- something that is not happening here.
  • Hi Primoz -- Well, if it is the first week contains four days *in that year* then it is the first week of that year (with that setting, at least!)....
  • I can't say that I'm an iso-8601 expert, but in Sweden we've adopted it extensively and the week numbers are used all over the place (as in "week 9 is the winter holiday in school").

    I think you can't really blame the standard for the definition of how to count weeks in a year. If you don't like the standard, don't follow it for your locale. At least there is a standard, and if you're unsure about how weeks are counted you can just say "are those ISO weeks or <foo> weeks?"

  • >>...if it is the first week contains four days *in that year* then it...<<

    I understand that, hence the :)

    But the wording is still wrong.

    Primoz
  • Hi Gustaf,

    You know what is even cooler? That this matches the Swedish locale settings on Windows, and I believe has since before this ISO standard even existed....

    But it would not be so nice if those were not the Swedish preferences and people blindly followed the "standard", instead.

    Its like that attempt to build a "European collation" that surfaces every few years.... as if it would really help people to make them change the alphabet they have known since they were young!
  • The standard is what it is. If you want to convert between SQL Server dates (in any combination of locale settings) and ISO 8601 dates, the information necessary to write such a conversion is there.

    That's the beauty of standards... there's enough for everyone to have their own.
  • Hmmm... shouldn't
    "First full week following 1/1 is the first week of that year."
    be
    "First full week following *the day before 1/1* is the first week of that year."
  • Using the quasi-legal 'reasonable man' standard? :-)

    ISO 8601 still sucks since it is pushed to the detriment of cultural diversity.....
  • "First full week starting on or after 1/1 of that year"

    Odd that all locales have seven-day weeks, come to think of it.
  • Odd how?

    Do you have a counter-example of a locale that would not be expected to have as seven day week?
  • (Mayan calendar link)
    http://webexhibits.org/calendars/calendar-mayan.html

    Soviet Union had a 5-day week in 1929-30, and a 6-day week in 1931

    Lithuanians had a 9-day week
  • Various weeks of different lengths:

    http://webexhibits.org/calendars/week.html

    French Revolutionary calendar used a 10-day week
    http://webexhibits.org/calendars/calendar-french.html

    Ancient Egyptians used a 10-day week
  • What are you trying to prove my point for me? Windows does not support any of these things....
Page 1 of 3 (41 items) 123