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…
Ask HN: Did you encounter any leap year bugs today?
231–240 of 498 posts
Re: Ask HN: Did you encounter any leap year bugs today?
#232Earlier 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 2000 was leap, but 2100, 2200, and 2300 won’t be, but 2400 will be.
Re: Ask HN: Did you encounter any leap year bugs today?
#233Re: Ask HN: Did you encounter any leap year bugs today?
#234Earlier quoted context omitted.
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 rule is that leap years are the ones divisible by 4. Unless it’s also divisible by 100. Unless unless it’s divisible by 400. So 2000 was leap, but 2100, 2200, and 2300 won’t be, but 2400 will be.
Thanks for answering
Re: Ask HN: Did you encounter any leap year bugs today?
#235Earlier quoted context omitted.
> now.replace(year=now.year-1) Yeah but this is bad code. Python certainly does have a "clean" way to subtract a year, you subtract a datetime.timedelta object.
timedelta doesn't take "years" as a parameter, for the reasons others have listed here. It's ambiguous what subtracting by a year means, and there's no real sensible default either.
from dateutil.relativedelta import relativedelta
one_year = relativedelta(years=1)Re: Ask HN: Did you encounter any leap year bugs today?
#236 irb(main):001:0> include ActionView::Helpers::DateHelper
=> Object
irb(main):002:0> distance_of_time_in_words(Date.new(2025, 2, 28), Date.new(2024, 2, 29))
=> "almost 1 year"
irb(main):003:0> distance_of_time_in_words(Date.new(2025, 3, 1), Date.new(2024, 2, 29))
=> "about 1 year"
irb(main):004:0> distance_of_time_in_words(Date.new(2025, 2, 28), Date.new(2024, 2, 28))
=> "about 1 year"Re: Ask HN: Did you encounter any leap year bugs today?
#237Heard from a friend in China: the age calculation portion of the app to schedule a marriage certificate had a bug where they subtracted 22 (legal minimum age) from the year, which resulted in 2002-02-29 which doesn't exist. The app intends to compare this against the user's birth date. The error handling code assumes all errors are from the comparison. The app then rejected all marriage certificate appointments by co…
How do leap day birthdays get handled in general? How is the right age iterated every year?
Re: Ask HN: Did you encounter any leap year bugs today?
#238Earlier quoted context omitted.
ChatGPT thinks today is March 1. Go ahead and ask it what today’s date is.
> No, 2024 is not a leap year. Leap years are years divisible by 4, except for years that are divisible by 100 unless they are also divisible by 400. Therefore, the next leap year will be 2024.
Re: Ask HN: Did you encounter any leap year bugs today?
#239We have a rails 6 app, and there's a test that essentially expects time_ago_in_words(1.year.from_now) to return "about 1 year" (as part of a user facing message). The test failed. I thought it's a flaky test but i was able to reproduce it locally. Turns out executing that code on a leap day returns "almost 1 year" instead. Can test it in rails console if you are interested: irb(main):001:0> include ActionView::Helper…
Curiously, this is also not quite a year, even though the days and months are the same.
Re: Ask HN: Did you encounter any leap year bugs today?
#240Heard from a friend in China: the age calculation portion of the app to schedule a marriage certificate had a bug where they subtracted 22 (legal minimum age) from the year, which resulted in 2002-02-29 which doesn't exist. The app intends to compare this against the user's birth date. The error handling code assumes all errors are from the comparison. The app then rejected all marriage certificate appointments by co…
How do leap day birthdays get handled in general? How is the right age iterated every year?
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).