Live data from Hacker News

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

news.ycombinator.com

341–350 of 498 posts

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

#341
post #103

We have a product that uses ChatGPT via the API, using the 3.5 turbo version. Our query involves some dates. Instead of giving back text like it usually does, today it has been giving errors because it does not think 2024-02-29 is a valid date. This is easy to reproduce with the web interface, at least sometimes [0]. It start out by saying it's not a valid date and then as it's explaining why it isn't it realizes its…

Blows my mind that people consider using ChatGPT for serious applications. I mean it's fine as a code autocorrect/autocomplete tool as in GitHub copilot. But it should not replace the code itself. You encounter a bug in the code, you fix it, you never encounter it again. But ChatGPT will repeat the same mistake sooner or later. That's not how we should engineer solution for critical problems.

If the cost-savings is worth it compared to the problems...

I mean, that's how we do it with humans. It's quite a common occurrence to keep a part of a business process human because automating it would we too expense due to edge cases.

Humans make mistakes and are expensive, but are also flexible and usually smartish. ChatGPT makes mistakes and is usually dumbish, but is also flexible and cheap.

Engineering is about picking the right trade-offs in your solution.

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

#343
post #323

Earlier quoted context omitted.

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?

This formula doesn't consider how we sometimes skip leap years, and sometimes have leap seconds, so it's vastly imprecise.

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

#344

Earlier quoted context omitted.

> distance_of_time_in_words(Date.new(2025, 2, 28), Date.new(2024, 2, 28)) Curiously, this is also not quite a year, even though the days and months are the same.

It’s probably comparing the number of days between the dates with the number of days in a year, which would usually work.

Source is a lot more complicated than i thought it will be: https://github.com/rails/rails/blob/v6.1.7.7/actionview/lib/...

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

#346
post #103

We have a product that uses ChatGPT via the API, using the 3.5 turbo version. Our query involves some dates. Instead of giving back text like it usually does, today it has been giving errors because it does not think 2024-02-29 is a valid date. This is easy to reproduce with the web interface, at least sometimes [0]. It start out by saying it's not a valid date and then as it's explaining why it isn't it realizes its…

Saw the same via the API with gpt-4-0125-preview. IOW, even gpt-4 thinks 2024 is not a leap year.

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

#348
post #297

Earlier quoted context omitted.

your function returns 29 days for every year not divisible by 400

!(x % y) is the same as (x % y == 0), which means the remainder is zero, so x is divisible by y. So it returns 29 if divisible by 400, 28 if divisible by 100, etc.

Oops, you are absolutely correct!

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

#349
post #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…

I've seen many date-related bugs similar to these and in very few cases it's as simple as "one developer was incompetent and did something stupid". Incompetence may be part of the problem, but in the background there are often data sources or services that provide the data in non-standard or unpredictable ways as well as specific business requirements that complicate the process.

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

#350
post #15

> A number of New Zealand petrol pumps stopped working on Thursday due to a "leap year glitch" in payment software, fuel stations and the payment service provider said. https://www.reuters.com/world/asia-pacific/leap-year-glitch-...

Related ongoing thread:

Self-pay gas station pumps break across NZ as software can't handle Leap Day - https://news.ycombinator.com/item?id=39553755 - Feb 2024 (31 comments)

Post reply on HN