Martin Spedding's Blog

Adventures in a disconnected world

How many months are there in a year ?

Silly question, but interesting if you are writing a program  and you want to return the months based on the culture of the user.

Instead of having to hand code all the month names all you have to do is write the following piece of code:

string[] _monthNames = System.Globalization.DateTimeFormatInfo.CurrentInfo.MonthNames;

so question is what is the length of _monthNames ?

You would expect 12 as there are normally 12 months in the year, but you would be wrong it is 13 !!

_monthNames[12] returns a blank string.

This is great if you are simply using _monthNames as a look for the names of the month but a bit of pain if you use it as the data source of a combo box.

I assume there must be cultures out there which have 13 months but why isn't the return string array dimensioned based on the current culture ?

Comments

Jerry Pisk said:

http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemGlobalizationDateTimeFormatInfoClassMonthNamesTopic.asp - the documentation is pretty clear on the fact that this is always going to have 13 elements. So once again I have to ask - does anybody read documentation these days?

As for the number of months - System.Globalization.DateTimeFormatInfo.CurrentInfo.Calendar.GetMonthsInYear(int year) will get you the info you want. And if you read the docs there's a note about HebrewCalendar having leap years, that have 13 months.
# June 10, 2004 5:52 PM

Achim said:

Martin did not question the fact, but the "why". And it is not made clear in the documentation, why there are always 13 months.
# June 11, 2004 3:45 AM

julie vang said:

why are there 12 months in a year
# July 1, 2004 2:59 PM

Shylah Watson said:

Answer the qestion how many months are there in a year???

# January 20, 2008 5:19 PM

jesica said:

I really need to know so please answer the question how many months are in  a year could someone please tell me?

# February 29, 2008 12:09 PM

Antonio said:

There are 13 months in a year. If 7 days make a week and four weeks makes a month, then there are 28 days in a month.( 7x4 is 28) If you add all of the months extra days january has 3 extra days with 31 february has 1 every four years, I'll tell you why I think that is after Im done explaining. march has three extra days at 31 april has 2 at 30 may has 3 at 31 june has 2 with 30 july has 3 at 31 aug has 3 september has 2 extra days october has 3 november has 2 and December has 3 when you add all of the months extra days you get the sum of 29.( a month and 1 day) 365 divided by 28 (days in a month) gives you 13 months in a year. 1 plus 3 equals 4 so they put that extra day in every four years. What i really would like to know is why leave out a whole month by rationing it out to 11 of the months but letting it stand true for only 1 month (february has 28 days) and if the 12 zodiac signs are to correlate to the months of the year then is there a 13th sign after pisces that the powers that be are afraid of recognizing. and whats more cool is if the sun was created first and mercury 2nd and venus 3rd then the 13 month earth would be fourth and 1 plus 3 makes 4 I think every planet has 28 days also ih a month because 2 plus 8 makes 10 or 1 ( 1 plus 0 equals 1), and the nine planets plus the sun makes 10 or 1. I also think that 9 is the number of completion and when a planet is complete or a solar system is comeplete it makes a circle and the first completion of a circle  consists of 360 degrees  and 3plus 6 plus 0 makes 9. so the 1 with a 0 behind it means the creator first and then a 0 which consist of an infinite number of 9 hint a zero is shaped like the universe and in an oval or 360 degrees or 540 or 720 or1080 or 1440 and so on each planet according to its size will have a year similar to the degree of a circle it is hint earth at 360 plus 5 a bussiness week. I could be wrong about the 28 a day month on other planets because a bigger planet like jupiter may have 55 or 64 days in a month or 91 or 82 or 37 or  73  I dont know but earth has 13 28 day months with 7 day weeks.

# July 12, 2008 8:40 PM

d said:

ddddddddddddddddddddddddddddddddddddddddddddd

# September 30, 2008 2:33 PM

ellie said:

i need to know !!!!!!!!!!!

# October 13, 2008 1:28 PM

CHARLIE said:

yooh DOPY  PERSON

ha ha ha ha!!!!!!!!!!!!!!

how many months in a year

HOW THIK CAN PEOPLE GET!

# October 30, 2008 5:53 PM

paul said:

oh My golly golly gosh!!

# October 30, 2008 6:00 PM

Hareem said:

how can you not know how many months there are in a year...

OBVIOUSLY 12.. check your calender!

# November 2, 2008 6:53 PM

_Pullywallayemuuk said:

Okaii so theres 12 months in all =/

DUHH

# May 31, 2009 4:26 AM

Dexter said:

Achim,

Jewish ppl have a cycle so it adds on a extra month

# May 31, 2009 4:30 AM

Parker said:

Omg to much typing im not reading it and 12 check ur calendar DUUUUUUUUUUUHHHHHHHHHH

# May 31, 2009 4:40 AM

Rhys said:

Jesica....YOU ASK THE DUMMEST QUESTIONS!!!!!!!!!!!TVELVE MONTHS IN A YEAR.....STORE THE INFORMATION HOW OLD ARE YOU 2!!!....wait two year olds can not type.......

# June 2, 2009 4:25 AM

yoniii said:

i guess there are 12 months a year but sory i'm not completely sure. !!!!!!!!!!

# June 16, 2009 5:43 AM

Lorna said:

u people r so dum check your calender 12 months in a year idots

# June 29, 2009 1:20 PM

jaremy said:

ya 12 months i hav eno idea how they got 13 but who cares

# July 31, 2009 8:14 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)