News for hackers. Stuff that matters.
Re:Ask HN: Did you encounter any leap year bugs today? by OJFord on Thursday February 29, 2024 @05:38PM (#39556179)
Moving bank/festive holidays, first Monday of the year(, first work day of the year not Monday if that's NYD and bank holiday), lunar occasions.

'subtract a year' is imprecise and has many meanings, if what you want is 'same day, same month, previous year' then say that and do that, that's conceptually `date.year -= 1` not `date -= 1 year`, and will have this bug.

Re:Ask HN: Did you encounter any leap year bugs today? by chatmasta on Thursday February 29, 2024 @06:15PM (#39556470)
You could subtract 365.25 days, but then you're left with a new problem: just because you can amortize a leap day over four years doesn't mean that you get an extra 6 hours each year.
Re:Ask HN: Did you encounter any leap year bugs today? by OJFord on Thursday February 29, 2024 @06:50PM (#39556802)
And as I just learnt elsewhere in this thread, it would actually be three four-hundredths less than that anyway, i.e. 365.2425, since only one in four centenaries is a leap year.