Live data from Hacker News

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

news.ycombinator.com

61–70 of 498 posts

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

#61
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…

[flagged]

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

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

which is why you should use arrow

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

#65
My suite failed this morning on an obscure test of a function that converts between ages and dates of birth. Took me ten minutes of head scratching before I realised it was Feb 29th.

’’’ + if time.Now().Month() == time.February && time.Now().Day() == 29 { + t.SkipNow() + } ’’’

Fixed.

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

#67
Yes, I have a bot that posts daily San Francisco weather records to Mastodon. It did not post as scheduled today. This is because I am looking at all the high temperatures, low temperatures, and precipitation on today's date from 1875 (about as far back as there are digitized weather records I can work with) to the present. Since there was no such date as February 29, 1875 it is throwing an error.

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

#70
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?

Yes - on any day, subtracting a year might mean subtracting the average length of a year (which is a bit more than 365 days), or wanting the same day and month number in the previous calendar year, or wanting the same semantic difference ("last Monday of the month in January"), to name a few possible meanings.
Post reply on HN