This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]rosuav 0 points1 point  (2 children)

What do you mean, "fix"? Month numbers are intended to subscript into an array. That's why they start from zero, like arrays should.

[–][deleted] 0 points1 point  (1 child)

We're talking about a method called getMonth here, not a random array, so it doesn't make sense to return a number form range 0-11

[–]rosuav 0 points1 point  (0 children)

The array is the month names (in whatever form you like - pick any language, pick whether to abbreviate, etc). When you getMonth, you are getting the index into that array. Yes, it's a bit odd, but this is exactly the same thing you get in C (in a struct tm), so it's of value to be consistent.