6

Possible Duplicate:
GetMonthName: Valid values are between 1 and 13, inclusive. Why?

The following code:

DateTimeFormatInfo datetimeinfo = new CultureInfo("en-GB", false).DateTimeFormat;
string[] months = datetimeinfo.MonthNames;

returns 13 members, with 0 being January and 13 being an empty string.

Why is this?

It's no big deal as I can just remove the last member, but I just wondered if there was a point to it.

Community
  • 1
  • 1
Piers Karsenbarg
  • 3,105
  • 5
  • 31
  • 67
  • 1
    Apparently to support calendars based on lunar months, see here: http://stackoverflow.com/questions/5991766/getmonthname-valid-values-are-between-1-and-13-inclusive-why – Kevin Wienhold Nov 25 '11 at 11:25

1 Answers1

7

Some calendars, notably the Hebrew, can have 13 months. This tends to be in lunisolar calendars which use Lunar months, and then add an extra month every few years to avoid the start of the year changing too much from the solar year.

Richard
  • 106,783
  • 21
  • 203
  • 265
  • But for the Hebrew culture, `MonthNames` also returns 12 "real" months and an empty one... – Thomas Levesque Nov 25 '11 at 11:28
  • @Thomas Levesque this may be simply a "feature" of MS implementation. For example the function that convert a string to title case (great britain => Great Britain) works the same way for Russian language, while actually in Russian it is correct to capitalize only the first letter of the first word (great britain => Great britain). – Vladimir Perevalov Nov 25 '11 at 11:39