Why does DateTimeInfo.MonthNames return a 13 member? [duplicate]
Asked Answered
V

1

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.

Visitor answered 25/11, 2011 at 11:20 Comment(1)
Apparently to support calendars based on lunar months, see here: #5992266Gambeson
L
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.

Langer answered 25/11, 2011 at 11:23 Comment(2)
But for the Hebrew culture, MonthNames also returns 12 "real" months and an empty one...Emissive
@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).Eusporangiate

© 2022 - 2024 — McMap. All rights reserved.