52 points · by expjpi · 4y ago · 28 comments
This Twitter thread from November 2020[1] and its HackerNews discussion[2] seem relevant.
1: https://twitter.com/hillelogram/status/1329228419628998665
[1]: https://en.wikipedia.org/wiki/French_Republican_calendar#Mon...
Which is probably because it's too fine a granularity, especially historically: even an ordinal month-day had limited use to preindustrial contexts were time-boundaries were necessary quite fuzzy owing to the vagaries of communications or transport.
Technically you don't need years either, but chunky boundaries are useful as both reference points and communication shortcuts.
const MONTHS = ["Jan", "Feb", "Mar", ..., "Dec"];
console.log(MONTHS[d.getMonth()]);Hence, dealing with months is perhaps a bit more like indexing variable-sized objects, and for that purpose traditionally, the array-of-pointers approach uses zero-based pointer arithmetic, which is what the designers might have been thinking.
Really however, the months should probably be treated more like structs, with the number of days in that month being a data member. This would allow sanity checks, i.e. entering Feb 30 should raise an error, but not May 30.
Year is 0 based too