Don't roll your own GetDateFormat

by Michael S. Kaplan, published on 2005/07/15 06:51 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2005/07/15/439223.aspx


A few days ago, Daniel asked (in the microsoft.public.win32.programmer.international newsgroup):

This issue is happening with MS Windows XP (all patches and updates) and MS Word XP (also all updates installed).

Until now, I thought that, when using the "Insert date and time" command from MS Word, it would take the month's name for the long date format from the Windows Regional Settings.

My belief, however must be wrong because, when I try to insert a long date format date in Latvian, the month name I get is different from the one I see in the Regional Settings.

This is what I get:

MS Word: when use the "Insert" -> "Date and Time" command to insert a long format date in Latvian, the date shown is "svetdiena, 2005. gada 10. julijs" (I have transliterated special baltic characters in case your reader does not support baltic characters).

MS Windows: Control Panel -> Regional and Language Settings -> "Latvian" as the language for "Standards and Formats". The long date displayed is "svetdiena, 2005. gada 10. julija" (again, baltic characters transliterated).

Both forms of the month's name (ending in "js" and in "ja" are correct, using one or another is a matter of style.

What puzzles me, however is: why isn't word using the same format as Windows? It seems that it has its own list of month's names. Where are they stored?

What I would like to achieve is that, when using "Insert date and time" from MS Word, the user gets the month's name with the "ja" ending instead of the "js" ending. Is there an easy way to achieve this?

Thanks in advance for your help!

Here are the strings for today, with the appropriate diacritics:

Word:      piektdiena, 2005. gada 15. jūlijs

Windows:   piektdiena, 2005. gada 15. jūlijā

Now some of the long-time readers here will immediately think back to my post What the %$#! are genitive dates? from December 25, 2004. And they will realize that the GetDateFormat function returns the second string. Which makes one wonder why Word 2002 (this problem also repros in Word 2003) is returning the wrong value.

The problem comes from rolling your own NLS functionality, rather than using the NLS functionality provided by Windows. Oops!

The NLS functions are able to handle a lot more complexities than they get credit for; in situations like this, they really shine. Of course, you do have to actually use the functions to get these benefits....

 

This post brought to you by "" (U+10fb, a.k.a. GEORGIAN PARAGRAPH SEPARATOR)


no comments

Please consider a donation to keep this archive running, maintained and free of advertising.
Donate €20 or more to receive an offline copy of the whole archive including all images.

referenced by

2010/09/09 Latvian. Genitive. Oops.

2008/05/14 Windows is too busy being consistent with the user to be consistent with itself!

2007/08/04 A re-genitive post

2005/07/15 Don't roll your own CompareString... uh... never mind

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