Don't roll your own GetDateFormat

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

Don't roll your own GetDateFormat

  • Comments 2

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)

Comment on the blather
Leave a Comment
  • Please add 1 and 6 and type the answer here:
  • Post
Blog - Comment List
  • People may recall that I have talked about genitive dates in whole heap o' posts: What the %$#! are genitive

  • The mail that came on the other day was: We’re seeing an issue that doesn’t seem correct to me, but I

Page 1 of 1 (2 items)