Live data from Hacker News

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

news.ycombinator.com

491–498 of 498 posts

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

#491
post #376

Earlier quoted context omitted.

> 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. Date library does not help here, for example, both Python and Java's date library [0][1] have only "days" in their timedelta/Duration constructor. Month and year are ambiguous. What would you do if you want someone's birthday this year? The most obvious way: birthday: datetime.date birthday…

The Java library actually supports this case. It may not have the convenient "years" method directly, but you can add an arbitrary unit of time quite easily Example with duration: Duration.of(1, ChronoUnit.YEARS) Example with datetime: today.plus(2, ChronoUnit.YEARS) It even supports decades, centuries, eras and half days :-) For those curious about how it handles leap years: var leapDay = LocalDate.of(2024, 2, 29) l…

Thanks! It does this according to doc:

    This method adds the specified amount to the years field in three steps:
      * Add the input years to the year field
      * Check if the resulting date would be invalid
      * Adjust the day-of-month to the last valid day if necessary
TIL. I didn't know that Java had a builtin calendar (instead of datetime) library.

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

#492
Kind of... Spent a while debugging an issue where the client was convinced he could not schedule new appointments in the system on the 29th.

It turned out he had set another setting incorrectly which was causing the appointment never to be valid.

But the rarity of the date let me wonder in the wrong direction for a while...

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

#493
post #449

Earlier quoted context omitted.

LOL, a good example of correlation does not equal causation.

It's not. There was no correlation at hand here - this was just a coincidence

anecdote is the singular of date, a correlate is a coincidence.

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

#494

I have a friend who was born on Feb 29, and in Quebec your driver's license fees must be paid on or before your birthday or your license is effectively revoked (It's a convenient reminder). He was on his way to pay them on the 29th and got pulled over for having an expired license... after some awkward common confusion with the police they came to the conclusion that the license bureau moves your "reminder" birthday…

Wouldn't the drivers license have the expiration date printed on it?

It's not the license expiration date is just the annual date that you need to pay your license renewal fees on.

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

#495

Earlier quoted context omitted.

I mean, they could have paid it any day before then, right? I would have just gone on the 28th and be done with it.

Sure...if you knew about this bug in the system.

If you are born on a Feb 29th, you should definitely get used to take this kind of precautions.

(Like I do when entering my last name that is legally spelled with an "é": I still get mojibake in 2024)

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

#496
Using Google Gemini:

Prompt:

> Is 1200-02-29 a valid date?

Answer:

> Python

>import datetime > >try: > datetime.datetime(year=1200, month=2, day=29) > print("Valid date") >except ValueError: > print("Invalid date") > >Output: > >Valid date > >Yes, 1200-02-29 is a valid date. > >According to the Gregorian calendar, leap years occur every four years except for years that are divisible by 100 but not divisible by 400. The year 1200 is divisible by 400, and therefore it is a leap year and February 29th exists in that year.

Wrong: the Gregorian calendar didn't yet exist in year 1200, so its rules don't apply for that year.

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

#497

Our Sophos anti-virus at work blocked access to every website this morning because of the leap year, had to disable the web filtering to get us back up and running.

Does anyone affected have a copy of one of the affected certificates? I'd be interested in seeing more detail on what went wrong.

The most likely thing to me would be that it attempted to issue a 1-year-long certificate, but naively produced a date of Feb 29, 2025.

Dates in certificates are encoded as `YYMMDDhhmmssZ` so it would certainly be possible to produce a certificate with an invalid date.

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

#498
post #346

Earlier quoted context omitted.

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

That's weird, I don't get that with gpt-4 https://chat.openai.com/share/336b1c4b-53b7-4d56-ac68-e3c868...

Given the probabilistic nature of LLMs, you likely need to run an experiment several times to see the various different results it can produce.
Post reply on HN