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.
Ask HN: Did you encounter any leap year bugs today?
391–400 of 498 posts
Re: Ask HN: Did you encounter any leap year bugs today?
#392Yes. > 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
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?
#393Earlier 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?
Re: Ask HN: Did you encounter any leap year bugs today?
#394Old 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?
#395Earlier 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…
Re: Ask HN: Did you encounter any leap year bugs today?
#396Didn't see it mentioned here but cloudflare sent me an invoice today and the attached PDF was titled cloudflare-invoice-1970-01-01.pdf :)
Re: Ask HN: Did you encounter any leap year bugs today?
#397Yes. > 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
https://en.wikipedia.org/wiki/List_of_non-standard_dates#Feb...
Re: Ask HN: Did you encounter any leap year bugs today?
#398Unless 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…
Re: Ask HN: Did you encounter any leap year bugs today?
#399I 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.
Re: Ask HN: Did you encounter any leap year bugs today?
#400Earlier 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?
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.