←back to thread

1021 points janpio | 1 comments | | HN request time: 1.02s | source
Show context
NelsonMinar ◴[] No.45676467[source]
Be sure to see the team's whole list of Cursed Knowledge. https://immich.app/cursed-knowledge
replies(6): >>45676661 #>>45677766 #>>45677816 #>>45678252 #>>45679167 #>>45680193 #
kyle-rb ◴[] No.45678252[source]
> JavaScript date objects are 1 indexed for years and days, but 0 indexed for months.

I don't disagree that months should be 1-indexed, but I would not make that assumption solely based on days/years being 1-indexed, since 0-indexing those would be psychotic.

replies(2): >>45678546 #>>45678812 #
kaoD ◴[] No.45678812[source]
The only reason I can think of to 0-index months is so you can do monthName[date.getMonth()] instead of monthName[date.getMonth() - 1].

I don't think adding counterintuitive behavior to your data to save a "- 1" here and there is a good idea, but I guess this is just legacy from the ancient times.

replies(1): >>45679173 #
1. oblio ◴[] No.45679173[source]
That would have a better solution in a date.getCurrentMonth(), in my opinion.