Live data from Hacker News

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

news.ycombinator.com

321–330 of 498 posts

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

#321

This one is rather specific, but a game rhythm based Final Fantasy game called Theatrhythm Final Bar Line is simply not allowing people to play today because it has an internal system that awards prizes for specific days and they didn't handle the case of what to do when it's on a leap day. You can boot it up but can't actually play the game as a result. Not working on the game or anything but found it moderately amu…

Yeah, this one was odd. I also ran into it.

https://gamerant.com/theatrhythm-final-fantasy-bar-line-not-...

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

#323
post #268

Earlier quoted context omitted.

Is March more logical? Feb 29 + 1 year = Feb 28.

By this logic, all birthdays would slowly drift as leap years pass.

Take DOB + n * 365.25 and then pick whatever day that falls in? That way it shouldn’t drift overall. Though, I guess it would imply that what day of the year people celebrate on, would be off by one day on leap years compared to what it is on other years?

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

#325
post #268

Earlier quoted context omitted.

Both Feb 28 and Mar 1 are commonly used to celebrate birthdays. AFAIK there is no firm convention. Feb is more natural ("My birthday is in February"), Mar is more logical (the 60th days of the year).

Is March more logical? Feb 29 + 1 year = Feb 28.

I asked JavaScript:

    const { format } = Intl.DateTimeFormat("en-UK", { month: "short", day: "numeric" });

    const date = new Date(2024, 1, 29);
    console.log(format(date));
    // 29 Feb

    date.setYear(2025);
    console.log(format(date));
    // 1 Mar

    const year = 1000 * 60 * 60 * 24 * 365.2425;
    console.log(format(new Date(2024, 1, 29).getTime() + year));
    // 28 Feb
I guess both are logical by some definition of logic.

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

#326
Had a pair of tests break CI.

At least one of them was the test, code it was testing did its job fine but test could not cope with February 29th. Obviously the test is broken in two different ways: it fails on Feb 29 and more importantly tests the behaviour on $current-date so only tests edge cases on the day of.

Other I didn’t follow.

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

#330
Stupid question. How do these bugs happen?

If you just take the naive approach and calculate everything as unix timestamp deltas, “yesterday” in human terms will still be 86400 seconds ago. No difference leap day or not.

If you use a date library with fancy “subtract one day” functions, it should also be handled automatically. Just like you don’t have to care that March has 31 days and April 30? No difference if leap day or not.

Someone must have spent a lot of effort to manually create date logic, hard coding the number of days in a month or something?

Only other edge case is if someone takes a 2024-02-29 timestamp and modify the year part, without using date library to do so. That should be rare, only use case is a yearly report. That’s not something that should take down the whole billing system.

Post reply on HN