There is no spoon^H^H^H^Hystem calendar

by Michael S. Kaplan, published on 2011/09/01 07:01 -04:00, original URI:

It was Mina who asked:

I was trying to change the system calendar using C#. I was trying to use setCalendarInfo but it keeps on failing because it is not clear what the last two parameters should be. Would you please advise on how to change the system calendar?

This one might have actually broken the record for bloggable issues found!

The first thing to notice is that there is no such thing as the system calendar -- the calendar is purely a per-user choice.

I suppose some think of the calendar of the LocalSystem account as a "system calendar", kinda, since LocalSystem is people, too! But a) it isn't, and b) that wasn't what was being asked.

Next, there's the function to use. It isn't SetCalendarInfo, which is only able to set the CAL_ITWODIGITYEARMAX value. The calendar is actually set by calling SetLocaleInfo, with the LCTYPE value of LOCALE_ICALENDARTYPE.

Then we have several doc bugs.

Like the fact that the LOCALE_ICALENDARTYPE incorrectly points to the Calendar Type Information topic (which contains the CALTYPEs), rather than the Calendar Identifiers topic (which contains the CALIDs we need).

Though I'm willing to be more forgiving of this one given how badly LOCALE_ICALENDARTYPE is named given what it is. :-)

Notice also that on the big list of functions that use Calendar Identifiers, you don't find SetLocaleInfo, GetLocaleInfo, or GetLocaleInfoEx (which is where LOCALE_ICALENDARTYPE is used -- as the actual potential values).

A lot of different potential ways to untangle these various problems, but it's gonna take some thought.

Looks like perhaps a meeting may be in my future with a doc writer.....

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.

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