Why are leap years a little tricky? The 8th of January will be Day 8 every single year but March the 1st will be Day 61 in leap years and Day 60 in common (non leap) years, the parser will need to account for this. This is the parser interface I’ve chosen:
YearDay(date).toString() YearDay(string) // to date
I’ve been reading about various date design proposals, there’s lots of them. Kevin sent me a link to NewCalendar which is pretty fun.
Dan thinks that if the world was asked to adopt a new date format then it would need a different year zero, that starting the count from Jesus’ ostensible birthdate is an atavistic piece of Eurocentrism. He’s not wrong. I suggest we propose an alternative year zero and include it the library as a non-default option.
- They use a dash (2019-235), I prefer a dot (2019.235)
- Their time format is human readable (HH:MM:SS), mine is not
- They pad out the day (2020-008), I prefer not (2020.8)
Ordinal dates are reasonably well supported across various date libraries so a YearDay parser will be trivial to write by just extending one of them. All-in-all though, date standards are a minefield that I won't wade into much further.