by Michael S. Kaplan, published on 2008/04/24 10:01 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2008/04/24/8420468.aspx
Content of Michael Kaplan's personal blog not approved by Microsoft (see disclaimer)!
Regular readers should keep in mind that all I said in The End? still applies; the allusion to the X-Files continues for people who understand such references....
You know, in many cases the date that you run into a problem can be rather ddirectly related to the actual problem.
I'm not thinking of what happens when you wear orange on Saint Patrick's day in Fishtown; I was thinking of programming issues. :-)
Frank Hauptlorenz's question to the microsoft.public.dotnet.internationalization newsgroup the other way was a really good example:
SUBJECT: DateTime.Now.toString("yyyyMMdd") depending on CultureInfo?
I have this instruction mentioned at top running on an japanese client.
Strangely this renders to "200809" (just year and day).
Has anybody an idea?
Now everyone can refresh their memory (or fill their cache, whichever!) by reading Long live the Emperor (ignoring the issue therein but paying attention to descriptive information) for some background on the Japanese Wareki calendar before I start blathering anew here....
Okay, we're all on the same page now?
This is a calendar that does not account for the idea of a reign longer than 100 years.
I mean, seriously -- how many of the 125 listed in Wikipedia's List of Emperors of Japan spanning 660 BC to present reigned for over 100 years?
If you do the math, you see an average reign of a little over 21 years, which is astounding given how young one could be to ascend....
But in any case, Windows follows suit here, and passing YYYY will be ignored because only YY is really going to be paid heed.
But (and this is where the timing comes into play) all of this was harder to spot since we are in the 20th year of the 平成 (Hensei) era which happens to be in the year 2008.
So when one is looking at 200809, one might tend to see 2008/09 rather than 20/08/09.
I guess you could think of this as one of the gotchas of ignoring cultural conventions (like that yyyyMMdd format) while still doing things in the context of a culture. Because culture will bite you in the butt if you aren't paying it its proper respect! :-)
This blog brought to you by 𐅹 (U+10179, aka GREEK YEAR SIGN)
Michael Madsen on 24 Apr 2008 7:06 PM:
"But in any case, Windows follows suit here, and passing YYYY will be ignored because only YY is really going to be paid heed."
But this behavior directly contradicts the documentation on date and time format strings - http://msdn2.microsoft.com/en-us/library/8kb3ddd4.aspx - where it essentially states that the number of Y's dictate the amount of digits. The same issue applies to the Taiwanese calendar.
Isn't it wrong anyway, considering the era is not mentioned? There's no way of telling the difference between 昭和20 and 平成20, since .NET doesn't add this on its own. .NET 1.1 uses the Gregorian year, so that's okay, but as of .NET 2.0, the developer will have to add it himself - and to top it off, .NET doesn't sem to define the era names, it just assigns an ID to each one and the developer will therefore have to map that in his own code (while making sure he won't have too many problems when the next era comes around and .NET is updated).
(On a side note, Japan uses both the era system and the Gregorian system for years, so the .NET 1.1 behavior doesn't seem entirely unreasonable to expect, even if you know of the era system.)
Michael S. Kaplan on 24 Apr 2008 8:00 PM:
Thankfully it only contradicts the documentation in scenarios that would really bother the people who care most about actually using those calendars. :-)
Maurits [MSFT] on 24 Apr 2008 8:46 PM:
> how many... Emperors of Japan... reigned for over 100 years?
Only one hundred years? Pshaw.
Dieci mille anni al nostro Imperatore! -- Turandot
Maurits [MSFT] on 24 Apr 2008 8:59 PM:
Emperor Kōan reigned 101 years, according to that article; Emperor Suinin 98 (no year 0)
Michael S. Kaplan on 24 Apr 2008 9:20 PM:
Usage of Windows (and computer usage in general) was not so high in either of those administrations. :-)
Per the Wikipedia article on the office of Emperor:
Over a thousand years ago, a tradition started that an emperor should ascend relatively young. A dynast who has passed one's toddler years, was regarded suitable and old enough. Reaching the age of legal majority was not a requirement. Thus, a multitude of Japanese emperors have ascended as children, as young as 6 or 8 years old. The high-priestly duties were deemed possible for a walking child. A reign of around ten years was regarded a sufficient service. Being a child was apparently a fine property, to endure tedious duties and to tolerate subjugation to political powerfuls, as well as sometimes to cloak the real powerful members of the imperial dynasty. Almost all Japanese empresses and dozens of emperors abdicated, and lived the rest of their lives in pampered retirement, and/or influencing behind the curtains. Several emperors abdicated/reached their entitled retirement while still in their teens. These traditions show in Japanese folklore, theater, literature and other forms of culture, where the emperor is usually described or depicted as an adolescent.
go to newer or older post, or back to index or month or day