Live data from Hacker News

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

news.ycombinator.com

391–400 of 498 posts

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

#391

Earlier quoted context omitted.

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

So make it more precise. DOB + n * 365.2421.

365.2425

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

#392
post #21

Yes. > During the morning on Thursday, no ICA store in Sweden could accept card payments. Instead, you had to use cash, Swish or pay via their app. > The reason behind the problem was an internal problem in the payment systems at ICA as a result of an extra day in February, leap day. ICA being the biggest grocery store chain in Sweden

And people in sweden look at me weird when I say I keep some cash around.

At least it wasn't 3 days like when Coop's provider got hacked. They also handle our pay checks at work… makes me feel so safe :D

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

#393
post #265

Earlier quoted context omitted.

Sadly, I can say from experience the American draft does not count the number of birthdays celebrated to figure out if you're eligible to serve.

You got drafted when you were five?

More like 4… since you can go to vietnam at 17. You're thinking of the age to drink a beer.

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

#394
I know I'm late to the party, but I have a Python script that creates a security.txt for one of my own project, and it sets the "Expires" date to one year in the future.

Old code:

expires = datetime.datetime.now(tz)

expires = expires.replace(year=expires.year + 1)

It broke yesterday, throws an exception ("ValueError: day is out of range for month"). It's kinda obvious that it does.

Fixed version code:

expires = datetime.datetime.now(tz) + datetime.timedelta(days=365)

expires = expires.isoformat(timespec="seconds")

Now we're just going 365 days into the future. Of course, this has a slightly different meaning and outcome, we are not always ending up on the "same date next year". But in this use case it doesn't really matter.

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

#395

Earlier quoted context omitted.

I'm sure it's more complicated than "we didn't think about leap years", but it certainly sounds pretty amateurish. Old programmer rant: In my day, we fixed the Y2K bug - we went to the future and back several times a day!

It does sound amateurish eh? I do most of my business logic inside Microsoft SQL Server Stored Procedure, and MS SQL just takes care of date pretty well. But then, come to think of it, you don't need to use SQL to have good date logic. C# and Java both have excellent date handing libraries. I don't know about C++, but I'd be surprised if there was not a modern date library for C++, so I am of the opinion there should…

[deleted]

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

#397
post #21

Yes. > During the morning on Thursday, no ICA store in Sweden could accept card payments. Instead, you had to use cash, Swish or pay via their app. > The reason behind the problem was an internal problem in the payment systems at ICA as a result of an extra day in February, leap day. ICA being the biggest grocery store chain in Sweden

Particularly odd since the Swedish calendar has had a lot of leap-day shenanigans, including a one-time Feb 30th.

https://en.wikipedia.org/wiki/List_of_non-standard_dates#Feb...

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

#398

Unless you're in your 70's, YouTube doesn't allow you to buy premium if you were born on a leap year, because their age calculation is broken, and it thinks you're under 18. Google One works fine. Support will suggest that you change the birthday on your Google account, which breaks account recovery processes that depend on you furnishing matching identity documentation. Mind-boggling. Because nobody at YouTube has a…

That should be a top comment here as it is most annoying and prevalent bug of all presented in this thread.

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

#399

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…

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.

Let me tell you about this human trait called procrastination.... actually I just have to do something first

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

#400
post #223

Earlier quoted context omitted.

Interesting... But that isn't exactly true! Centuries that are not divisible by 4 don't count!

I've yet to come across a form of 100 that isn't divisible by 4... since 25 usually still exists! But I do remember there being some weird niche rules about which years are or aren't leap years, so I'm guessing your comment is basically right just wrongly worded?

The GP formulated it in a somewhat unclear way. "Centuries" divisible by 4 probably meant "years" divisible by 400.

So, 19th century (1900 is the last year) isn't divisible by 4 (19/4 is not integer), which is the same as saying that 1900 isn't divisible by 400.

This is the main reform of the Gregorian calendar - leap days aren't introduced on xy00 years which aren't divisible by 400. This corrects the length of a year to 365.2425 days, which is fairly close to the real value of 364.2422 days.

The original Julian calendar had year of 365.25 days, which aggregated an error of more than ten days over the centuries.

Post reply on HN