Live data from Hacker News

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

news.ycombinator.com

71–80 of 498 posts

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

#71
post #4

One cleanup script broke because Python doesn’t have a clean way to subtract a year, and if you do now.replace(year=now.year-1), you get a ValueError when now is 2/29. It’s easy enough to address. There are various StackOverflow posts on such things. Here is one: https://stackoverflow.com/questions/54394327/using-datetime-...

I get it if you don't want to bring in another dependency, but Arrow has a lot of nice utility methods: https://arrow.readthedocs.io/en/latest/guide.html#replace-sh...

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

#72
post #29
post #9

Earlier quoted context omitted.

That's generally risky to do nowadays because of things like TLS certificate expiration.

In a few hours you'll be able to backdate to "yesterday", with very low chances of hitting cert expiry issues (but I wouldn't be surprised if OP's issue involves components outside of their control or ability to test end-to-end)

I should have written something along the lines of "validity date ranges" instead of expiration: you're much more likely to run into problems where you run into a certificate that was issued in the future relative to when you think is now.

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

#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 it.

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

#76
post #23

Heard from a friend in China: the age calculation portion of the app to schedule a marriage certificate had a bug where they subtracted 22 (legal minimum age) from the year, which resulted in 2002-02-29 which doesn't exist. The app intends to compare this against the user's birth date. The error handling code assumes all errors are from the comparison. The app then rejected all marriage certificate appointments by co…

Haha, that would be quite the appropriate place to put one of those "Please wait and try again" error messages.

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

#78
post #18

Earlier quoted context omitted.

What is your definition of "subtracting a year"? Seems like that's a relatively ambiguous operation without more specification.

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

Worth a mention... Falsehoods Programmers Believe About Time: https://news.ycombinator.com/item?id=4128208

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

#80
Our ETL process is heavily monitored so we never miss a days data, but we got a surprising error "cant build aggregates - missing data, aborting MV refresh, data will be a day old". It was the year to date (YTD) calculation - no data for 29/2/2023 to compare to today.
Post reply on HN