Live data from Hacker News

Ask HN: Did you encounter any leap year bugs today?

news.ycombinator.com

121–130 of 498 posts

Re: Ask HN: Did you encounter any leap year bugs today?

#121
post #99

Why are there so many stories about leap year bugs?

It’s strange to me, it hasn’t been than long since a leap year and I don’t remember as many last time.

It’s the first go-around for the jr devs who went to school during the pandemic :)

Re: Ask HN: Did you encounter any leap year bugs today?

#122

The other way around! Today a few services that don't congratulate me on my birthday (on non-leap years) did. I was born on February 29th.

How often do you encounter challenges related to your birthday? Meaning, not just on the day of Feb 29, but any day of the year when you're trying to select your birth date or something like that. Do you ever find forms where the date is missing or the backend wont accept it?

Re: Ask HN: Did you encounter any leap year bugs today?

#123
post #106
post #43

Earlier quoted context omitted.

But then it'll be off by one day for the rest of this year. And someone will notice that they no longer have March 1 2023-March 1 2024 in their chart, but March 2 2023

It's a cleanup script. I bet nobody cares it's off by one day. Also I doubt a cleanup script has a charting function. Everything is use case dependent. Sometimes the use case is unimportant enough that mistakes are okay.

While that's true, I'm sharing scar tissue here not hypotheticals.

There's often someone out there who interprets such things as a 3 month, or 1 year retention policy and that it means they're entitled to look at the entire range whenever they want.

Re: Ask HN: Did you encounter any leap year bugs today?

#124
post #95

Earlier quoted context omitted.

Can you think of any situation where subtracting a year from today's date is ambiguous when today isn't, well, today?

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.

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?

#125

Yes - I triple-checked the calendar to verify my suspicion this February might have 29 days. The result was always negative - it seemed 28. Then February the 29th actually came. A bug apparently occurred in my mind.

I can also never remember if "leap year" means 29 days or 28 days, and which one is normal. I probably checked that twelve times this week. And I was mildly surprised when I noticed that March 1 was Friday and not Thursday...

Re: Ask HN: Did you encounter any leap year bugs today?

#127

The other way around! Today a few services that don't congratulate me on my birthday (on non-leap years) did. I was born on February 29th.

How often do you encounter challenges related to your birthday? Meaning, not just on the day of Feb 29, but any day of the year when you're trying to select your birth date or something like that. Do you ever find forms where the date is missing or the backend wont accept it?

Occasionally, but less often than one could imagine! About a dozen times in my life.

Whenever February 29 wasn’t present as an option, the frontend was at fault, so I could set the right value in the inspector as a workaround.

Other times February 29 was present as an option, only to be saved as February 28. Never March 1, which I’d say would be more coherent.

Re: Ask HN: Did you encounter any leap year bugs today?

#130
post #74

I certainly did. There is a batch process to cull old records. It checks for customers who do not have a date of death recorded but are > 130 years old, as it assumes that we weren't informed of their death. It takes 130 years from the current date and uses that in an SQL statement to compares it to the date of birth. DB2 doesn't like 1894-02-29. Apparently it happens every 4 years, but no-one can be bothered to fix…

A simple fix would be to change it to a multiple of 4 (e.g. 124 years). Then it would fail every 100 years.

128! It was right there!
Post reply on HN