Date petpeeve

Mar 8, 2010 at 3:33 PM

Hi,

This is not a bug per se, but it can be a source of confusion.

 

var x = new Date(2000, 0, 1); // Jan, first of 2000

Months are 0 based, but days are 1 based... it is not consistent.

Can you guys make months to be 1 based too? it will be consistent and it will read much more natural.

Jorge

 

Coordinator
Mar 8, 2010 at 4:09 PM

Hi,

 

This is how it is defined in the ECMAScript standard. Since we want to respect as much as we can, we would not change this.

 

Nicolas.

Mar 8, 2010 at 4:23 PM

Hi,

I couldn't believe it, but I you are absolutely right.

In the standard (http://www.ecma-international.org/publications/standards/Ecma-262.htm), in the PDF page 165, item 15.9.1.4, first paragraph explain that months are numbered from 0 to 11. While in the same page, next point 15.9.1.5 does say that days are 1 to 31.

I cannot possible imagine what were the talks that they concluded that this is the best representation.

Jorge

Coordinator
Mar 9, 2010 at 7:04 AM

Hi,

Me neither, but there must be a reason, I think they are much more clever than you or I, or at least, I hope so ;-)

Mar 9, 2010 at 12:38 PM

Hi,

I don't know about cleverness... sometimes decisions like this one are made out of political advantages rather than technical ones.

Jorge.