ISO 8601 is asinine

by Michael S. Kaplan, published on 2005/11/14 01:01 -08:00, original URI: http://blogs.msdn.com/michkap/archive/2005/11/14/492249.aspx


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:

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)


# gabr on Monday, November 14, 2005 4:57 AM:

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

# Nick Lamb on Monday, November 14, 2005 6:54 AM:

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?

# Michael S. Kaplan on Monday, November 14, 2005 7:24 AM:

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.

# Michael S. Kaplan on Monday, November 14, 2005 7:26 AM:

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!)....

# Gustaf Erikson on Monday, November 14, 2005 8:24 AM:

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?"

# gabr on Monday, November 14, 2005 8:32 AM:

>>...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

# Michael S. Kaplan on Monday, November 14, 2005 10:06 AM:

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!

# Maurits on Monday, November 14, 2005 2:50 PM:

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.

# Maurits on Monday, November 14, 2005 2:53 PM:

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."

# Michael S. Kaplan on Monday, November 14, 2005 3:29 PM:

Using the quasi-legal 'reasonable man' standard? :-)

ISO 8601 still sucks since it is pushed to the detriment of cultural diversity.....

# Maurits on Monday, November 14, 2005 4:28 PM:

"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.

# Michael S. Kaplan on Monday, November 14, 2005 4:40 PM:

Odd how?

Do you have a counter-example of a locale that would not be expected to have as seven day week?

# Maurits on Monday, November 14, 2005 5:04 PM:

(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

# Maurits on Monday, November 14, 2005 5:07 PM:

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

# Michael S. Kaplan on Monday, November 14, 2005 5:09 PM:

What are you trying to prove my point for me? Windows does not support any of these things....

# Maurits on Monday, November 14, 2005 5:18 PM:

I'm just pointing out an assumption that is being made by the core Windows code... that all customer locales agree on the length of a week (seven days.)

Since 1931, that has indeed been true.

However, since there have been disagreements in the past, it seems safe to presume that there will arise disagreements in the future.

At that point, a fair amount of code will need to be reworked.

# Maurits on Monday, November 14, 2005 5:21 PM:

Sorry, it was on 26 June 1940 that the USSR reverted to the seven-day week, not in 1931.

# Maurits on Monday, November 14, 2005 5:35 PM:

Who am I to disagree with both Microsoft and Google?

http://search.msn.com/results.aspx?q=1+week+in+days
http://www.google.com/search?q=1+week+in+days

# Maurits on Monday, November 14, 2005 5:47 PM:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemglobalizationcalendarweekruleclasstopic.asp

"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."

Hmmm... that can't be right, can it?

How about "The week that contains the fourth day of the year?"

That makes it all very simple:

FirstDay:
The week that contains the first day of the year, minus any days before the first day of the year.

FirstFourDayWeek
The week that contains the fourth day of the year, minus any days before the first day of the year.

FirstFullWeek
The week that contains the seventh day of the year.

# Michael S. Kaplan on Monday, November 14, 2005 7:24 PM:

Of course the problem then would be to convince people that the definitions have not changed. :-)

# Maurits on Monday, November 14, 2005 7:46 PM:

Many businesses define the "first week of the year" as the week containing the first WEEKDAY of the year, where weekdays are defined as Monday through Friday.

Practically speaking, this is:

The earlier of (the week containing the first Monday of the year) and (the week containing the first Friday of the year), minus any days before the first of the year.

Tuesday through Thursday need not be checked, due to convexity...

# Nick Lamb on Monday, November 14, 2005 8:08 PM:

"to the detriment of cultural diversity....."

It's a pretty poor culture that exists just to declare itself arbitrarily different.

"If it is human readable than it ought to prefer user preferences for locales."

That would be applicable in some applications, but it's certainly not good enough for a rule-of-thumb let alone a standards document. ISO 8601 is aimed at interchange, as a format that's unambiguous to /humans/ and that means it would be pointless to store your data using ISO 8601 only to print it out with US-style dates and fax them to your Tokyo and London offices.

# Maurits on Monday, November 14, 2005 8:10 PM:

Hmmm... by inspection, you don't need to check Monday either. The week containing the first Friday is always the same as, or earlier than, the week containing the first Monday.

# Michael S. Kaplan on Monday, November 14, 2005 8:24 PM:

Nick -- I am not giving reasons for their diversity. They ARE different, and have been since before this standard even existed. What is, IS, and needs no excuse or explanation.

Maurits -- since most of the standards we are based on do not use this method of explanation, it would not work, even of there were no change....

# Marvin on Tuesday, November 15, 2005 2:57 AM:

Re: "Cultural diversity"
This is a red herring. The way people measure has very little to do with culture. My grandfather didn't use kilograms and meters and yet I belong to the same culture as he did. British switched to decimal currency and did not become less distinct from Americans. Modern Israelis use Gregorian calendar almost exclusively (apart from some formal and religious occasions) and nobody thinks they are less Jewish for that. Heck, some countries even switched from left-hand-side to right-hand-side driving without loosing a bit of their culture ;-)
The "weights and measures" standards are arbitrary things that can be changed at a whim. Bringing "cultural diversity" into technical discussion about them is just relying on taboo words.
(Since you are a fan of Steven Pinker a nice discussion of invoking taboo principle can be found in his "The Blank Slate" ;-)

# Michael S. Kaplan on Tuesday, November 15, 2005 6:32 AM:

Marvin -- I hear you. But I also know that these preferences that people have existed before there even were computers. And the idea is to allow people to be comfortable with computers, not vice versa.

And the best way to do that in the opinion of those who designed the locale model used by many companies including Microsoft is to store those preferences and use them (and in some cases allow indvidual overrides).

# Gabe on Tuesday, November 15, 2005 11:25 AM:

I think SQL Server will default to the first day of the week as specified in its default locale. However, you can use SET DATEFIRST to change it (1 is Monday; 7 is Sunday).

# Marvin on Tuesday, November 15, 2005 12:23 PM:

I agree. It is certainly not Microsoft's or any other company's job to tell people what to do. However, this has nothing to do with ISO 8601 standard. Standards like it exist to allow people to communicate. It is good that MS software allows me to use pounds and feet when I need them but when I need to send data abroad it should better support kilograms and meters too. You wouldn't call SI units (also I think an ISO standard) asinine, would you? Microsoft's locale oriented approach is one good thing and international common date and time standard is another. They don't compete with each other.

# Isaac Lin on Tuesday, November 15, 2005 5:03 PM:

Michael, I also work for a large, multinational company who has employees, contractors, and customers in many different countries. Our release schedules are tracked by week number, so it is a big help for everyone to agree on a single way to count the week numbers, and each year we release an official company calendar with our week numbers. Any standard can be followed (witness Kodak using the reformed calendar that George Eastman touted up until very recently, as I recall) as long as its consistent, but it might as well be a single, agreed upon standard, and ISO 8601 fits that purpose. I certainly think software and OSs should allow localization of the date format, including week numbering -- but an easy way to support a standard format is also desirable in today's global economy.

# Maurits on Tuesday, November 15, 2005 5:13 PM:

> Standards like it exist to allow people to communicate.

Agree 100%. There's a reason all diseases have Latin names in the medical arena - so doctors can agree on what to call them. That way a doctor only has to learn one extra language (Latin) besides what he needs to serve his local patients (one or more of various languages, depending on where he lives) and to communicate with his local staff.

The fact that no regions currently speak Latin is irrelevant.

# Michael S. Kaplan on Tuesday, November 15, 2005 5:31 PM:

Hey Maurits -- so is the epidemic called HIV or LAV?

Language enters even into medicine....

# Maurits on Tuesday, November 15, 2005 7:24 PM:

HIV is Latin. Well, at least, the following words are all of Latin origin:

Human
Immune
Deficient
Virus

Lymphadenopathy-associated-virus is a hybrid of Latin and Greek:

Latin:
Lymph
Associated
Virus

Greek:
Adeno-
-pathy

So LAV is the "colloquial" term for a particular branch of HIV?

It's weird to see a word beginning in "lymph-" and ending in "-pathy"...

# Michael S. Kaplan on Tuesday, November 15, 2005 7:31 PM:

I guess you missed my point, which is that language and culture still manage to elbow their way in, always.

# Maurits on Tuesday, November 15, 2005 8:06 PM:

> language and culture still manage to elbow their way in, always

Agreed...

# scooby on Wednesday, November 16, 2005 9:22 AM:

This may be simplistic, but why not just implement ISO8601 as another locale that users could pick?

# AntoineL on Wednesday, November 16, 2005 9:34 AM:

> Many businesses define the "first week of the year" as the week containing the first WEEKDAY of the year,

Yes, it makes sense

> where weekdays are defined as Monday through Friday.

Well, not everywhere. If I call a client in Algiers on Friday morning, I probably will not be welcome...

Also, most people will exclude the traditionnal fixed notworking days from the count; that is, in Christian regions, 1/1 is usually NOT counted as a weekday.


And this really boilds down to decide if the first day of the week is the first "weekday" (as it is in some part of Europe, and then LOCALE_IFIRSTWEEKOFYEAR=2 does the job; that the reasonning behind ISO 8601 BTW), or if it is instead a rest day (a widely used religious interpretation); or even something else.

Perhaps we are missing some distinct locale information here?

# AntoineL on Wednesday, November 16, 2005 9:47 AM:

Michael,

> the idea is to allow people to be comfortable with computers, not vice versa.

Sure.
However, when it comes to week _numbers_, it has always been my interpretation there is a (fairly recent) derived unit, not a basic one. I mean, people do not tend to keep their idea of time using this scale, rather they record the day of the month, and when they need the weeknumber they look at the calendar.

Of course, a lot of people record the oddness of the week number; but I do not believe they are interested in the number per se (and I also see they often paint the wall calendars...)

Note this is my view from Western Europa, where week numbers are not overused: the main use of them are for production control, and there a lot of numbers (ultimately related with computers, of course) invade our lives anyway.

# mfx on Friday, November 18, 2005 8:30 AM:

I live in germany, and work with companies that employ week numbers for most calendaring tasks. So far as i know, most countries have "culturally accepted" scheme of week numbers, in the sense that week numbering is not something that kids are taught in school when the calendar is explained.

Every week numbering scheme has the same basic problem: weeks don't fit precisely into years. If we want to have "full weeks" only (no week number splits in mid-week), we will have weeks 52 or 53 that extend into the next year, or we have a week 1 that extends into the former year.

Every week numbering scheme is to some extent arbitrary, and there exists no obviously correct solution: there are at least two possibly "first days" in a week (sunday/monday), and the first week can be defined to be the first "full week" or the first week that is "mostly" in the new year (the iso definition), so we end up with at least 4 different possibilities to define week numbers.

To summarize: the solution defined in iso 8601 is as good as any, and it is a standard formally accepted by most countries, so i would expect that major software supports it.

It always irks me to see software that doesn't support international time/date standards, but defaults to US-specific defaults that are not used anywhere else in the world (especially 12-hour times and the am/pm convention that is utterly error-prone at noon and midnight, but thats a different topic).

referenced by

2010/10/03 It's always back to ISO-8601 for some reason

2008/03/09 When in doubt, blame it on the @#%&*! SMILERS

2007/09/03 SIAO: As unofficial as you can get without a prescription

2006/01/26 ISO 8601 redux

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