I ran into an interesting problem with a Vista sidebar calendar gadget. It seems that it is not exactly trivial to find out interesting NLS data like localized month names, first day of week, etc. from JScript.
Eventually I found a workaround for some of the data. VBScript has MonthName, WeekDayName and WeekDay functions that can be used for some of the data I was looking for. These can be wrapped in VBScript functions which JScript can then call from the same page. I calculated FirstDayOfWeek information by using the WeekDay function for a known date.
These are the helpers that I ended up with:
‘ Helper functions so we can do this in JScript as well
MyMonthName = MonthName(month)
MyAbbrevMonthName = MonthName(month, True)
MyDayName = WeekDayName(day)
MyAbbrevDayName = WeekDayName(day, True)
‘ Get First Day of Week where 1 is Sunday, 2 is Monday, etc.
MyDate = DateSerial(2002, 9, 1) ‘ A Sunday
FirstDayOfWeek = (9 – WeekDay(MyDate, 0))
if FirstDayOfWeek = 8 then FirstDayOfWeek = 1
Unfortunately some items like Shortest Day Names and Month/Year patterns can’t be retrieved this way, but I was able to solve most of my problem. The attached CalendarData.html uses these helper functions to dump the values I was interested in using both VBScript and JScript.
I also embedded the HTML here, so here’s the output, hope this is interesting: