Ask HN: Did you encounter any leap year bugs today?
131–140 of 498 posts
Re: Ask HN: Did you encounter any leap year bugs today?
#132Why are there so many stories about leap year bugs?
Because programmers take shortcuts. Its easier to type x - 365 than to import Calendar and then date(x) - timedelta(1 year).
Properly designed date/time API invented relatively recently.
System.DateTime (.NET) - 2002 | System.DateTimeOffset - 2005
Joda time (JVM) - 2005 | java.time - 2014
Temporal (JavaScript) - still experimental
Re: Ask HN: Did you encounter any leap year bugs today?
#133I can understand getting the years 2000 (leap), 2100 (not leap), 2200 (not leap), and 2300 (not leap) wrong. But getting the year 2024 wrong is, disappointing, to put it diplomatically.
Re: Ask HN: Did you encounter any leap year bugs today?
#134The 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.
Re: Ask HN: Did you encounter any leap year bugs today?
#135:)
Re: Ask HN: Did you encounter any leap year bugs today?
#136Heard 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?
#137I had a unit tests for a Java LocalDate that was being increased by one year. It checked whether the month and day were the same, and failed because the current day (29) didn't equal the year-hence one (28). I changed it to check that the difference between the days was less than two.
Re: Ask HN: Did you encounter any leap year bugs today?
#138Re: Ask HN: Did you encounter any leap year bugs today?
#139The 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.
...it occurs to me, when should those services congratulate you? Should it be on February 28 or March 1?
Which makes sense since then it is "after" your birthday.