Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Wozza638787yInteresting, if the input was 1-12 then it may be more efficient to do this in terms of CPU cycles, one less subtraction per array access. Unconventional but I quite like it!
-
It's a convention that days/months arrays start from 1. It is also used in Python's calendar built-in module.
-
@kunashe It's very convenient to use, not look at. How awkward it would be to do arr[11] and get December?
-
kunashe19877y@DeepSpace you have a point. I suppose it’s necessary to weigh up whether it’s appropriate for the month array to also return an empty string as a valid month.
I’d be concerned that I may have to make other fudges for cases like:
$year[$month[0]]
Related Rants
Arrays start from 0... 1?
undefined
colleague
arrays
fail