News for hackers. Stuff that matters.
Re:Ask HN: Did you encounter any leap year bugs today? by xattt on Thursday February 29, 2024 @06:49PM (#39556788)
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? by ao98 on Thursday February 29, 2024 @06:58PM (#39556855)
The most common approach I’ve seen is to alias them to Mar 1st.
Re:Ask HN: Did you encounter any leap year bugs today? by DinaCoder99 on Thursday February 29, 2024 @08:58PM (#39557646)
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.
Re:Ask HN: Did you encounter any leap year bugs today? by qup on Thursday February 29, 2024 @09:51PM (#39558010)
You got drafted when you were five?
Re:Ask HN: Did you encounter any leap year bugs today? by guappa on Friday March 01, 2024 @03:50AM (#39559928)
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? by qup on Friday March 01, 2024 @04:15AM (#39560075)
Can't get drafted at 17. I don't know if you can go or not.
Re:Ask HN: Did you encounter any leap year bugs today? by guappa on Friday March 01, 2024 @05:56AM (#39560603)
Raffaele Minichiello volunteered at 17.

https://it.wikipedia.org/wiki/Raffaele_Minichiello

Re:Ask HN: Did you encounter any leap year bugs today? by qup on Saturday March 02, 2024 @01:30PM (#39574634)
Volunteering is the opposite of getting drafted
Re:Ask HN: Did you encounter any leap year bugs today? by paulddraper on Thursday February 29, 2024 @09:03PM (#39557685)
Both Feb 28 and Mar 1 are commonly used to celebrate birthdays.

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).

Re:Ask HN: Did you encounter any leap year bugs today? by js2 on Thursday February 29, 2024 @09:53PM (#39558027)
Is March more logical? Feb 29 + 1 year = Feb 28.
Re:Ask HN: Did you encounter any leap year bugs today? by silisili on Thursday February 29, 2024 @11:26PM (#39558528)
Think of it this way: if Feb 29 didn't exist that year, it would have been March 1.

If we're being scientific I guess all of us should move our birthday up by 1 day on leap years, but that seems annoying and not sure anyone really cares enough to.

Re:Ask HN: Did you encounter any leap year bugs today? by prmoustache on Friday March 01, 2024 @05:15AM (#39560383)
No we should move our birthday celebration up by 6 hours every year. But that would be only relevant if we were celebrating at the exact hour of our birth.
Re:Ask HN: Did you encounter any leap year bugs today? by remram on Saturday March 02, 2024 @12:10AM (#39570023)
We already don't move them for timezones. I was born at 3am but in France, when I'm in the US I don't celebrate the day before.
Re:Ask HN: Did you encounter any leap year bugs today? by edflsafoiewq on Friday March 01, 2024 @12:07AM (#39558710)
By this logic, all birthdays would slowly drift as leap years pass.
Re:Ask HN: Did you encounter any leap year bugs today? by drdeca on Friday March 01, 2024 @01:05AM (#39559019)
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?
Re:Ask HN: Did you encounter any leap year bugs today? by iforgotpassword on Friday March 01, 2024 @01:57AM (#39559293)
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? by munch117 on Friday March 01, 2024 @02:20AM (#39559421)
So make it more precise. DOB + n * 365.2421.
Re:Ask HN: Did you encounter any leap year bugs today? by histories on Friday March 01, 2024 @03:45AM (#39559899)
365.2425
Re:Ask HN: Did you encounter any leap year bugs today? by shzhdbi09gv8ioi on Friday March 01, 2024 @04:58AM (#39560279)
365.2421 is more correct.

Nasa explains:

365 +0.25 - 0.01 + 0.0025 - 0.00025 = 365.24225

https://pumas.nasa.gov/examples/how-many-days-are-year

Re:Ask HN: Did you encounter any leap year bugs today? by histories on Friday March 01, 2024 @06:56AM (#39560922)
>Omitting a leap year every 4000 years

Wait, is this right? omitting every 100 and adding every 400 should be enough.

EDIT: the 4000-year rule is just a proposal for now. So 365.2425 is correct.

Re:Ask HN: Did you encounter any leap year bugs today? by mark-r on Friday March 01, 2024 @08:24AM (#39561527)
None of us will live long enough to see the 4000-year rule become a problem. I don't even expect to be around for the next 100-year rule.
Re:Ask HN: Did you encounter any leap year bugs today? by jey on Thursday February 29, 2024 @10:07PM (#39558116)
What’s the significance of 365? Each Earth year has just a smidge under 365.25 days.
Re:Ask HN: Did you encounter any leap year bugs today? by carleverett on Friday March 01, 2024 @12:00AM (#39558681)
But 1 day is still 24 hours.

If you want to celebrate your birthday at the moment earth reaches the same spot around the sun as when you were born, then we’d all have the same issue - we’d have to celebrate it 6 hours later every year, reseting every 4 years.

February 29 is very much a new day… which simply doesn’t exist on non-leap years.

Re:Ask HN: Did you encounter any leap year bugs today? by js2 on Thursday February 29, 2024 @10:28PM (#39558229)
365 days is what people commonly think of as a year. So if you're born Feb 29th and celebrate your birthday one year later (whether you call that 365 or 365.25), you land on Feb 28th. Then again, folks born between Jan 1 and Feb 28th of a leap year celebrate their birthdays 366 days later by calendar days.

Anyway, I'm not sure there's any more or less logical date to use and Feb 29th babies seem to choose both about equally:

> “I love when people ask me, ‘Do you celebrate on Feb. 28 or March 1?’” said Raenell Dawn, a co-founder of Honor Society of Leap Year Day Babies. “I get to tell them, ‘Both, because I can.’ But I’m a February baby; I was not born in March.” An informal poll of the society’s members showed about a 50-50 split between the two dates, said Ms. Dawn, who is celebrating her “Sweeter 16” by turning 64 this year.

https://www.nytimes.com/2024/02/28/style/leap-year-explained...

Re:Ask HN: Did you encounter any leap year bugs today? by dexterdog on Thursday February 29, 2024 @11:19PM (#39558496)
Celebrating on the 28th makes no sense. That is when you celebrate your Birthday Eve every year so your birthday is the next day, whatever that is.
Re:Ask HN: Did you encounter any leap year bugs today? by smrq on Friday March 01, 2024 @12:01AM (#39558685)
You can make the same argument that March 1st makes no sense, as that is the day of your birthday hangover, the day after whenever your birthday is.
Re:Ask HN: Did you encounter any leap year bugs today? by pests on Friday March 01, 2024 @12:22AM (#39558808)
Similar to the recent standup maths video where the town did it's art installation incorrectly - the fence post problem / off by one.

https://youtu.be/FAdmpAZTH_M?si=r_INH_C5j9mbpJSh

Re:Ask HN: Did you encounter any leap year bugs today? by runarberg on Friday March 01, 2024 @01:15AM (#39559054)
I asked JavaScript:

    const { format } = Intl.DateTimeFormat("en-UK", { month: "short", day: "numeric" });

    const date = new Date(2024, 1, 29);
    console.log(format(date));
    // 29 Feb

    date.setYear(2025);
    console.log(format(date));
    // 1 Mar

    const year = 1000 * 60 * 60 * 24 * 365.2425;
    console.log(format(new Date(2024, 1, 29).getTime() + year));
    // 28 Feb
I guess both are logical by some definition of logic.
Re:Ask HN: Did you encounter any leap year bugs today? by paulddraper on Friday March 01, 2024 @06:59PM (#39568346)
I can agree with that.
Re:Ask HN: Did you encounter any leap year bugs today? by paulddraper on Friday March 01, 2024 @01:40AM (#39559195)
You're begging the question. [1]

"Feb 29 + 1 year" is verbatim restatement.

---

You can say Feb 29 + 365 days = Feb 28. (And Feb 29 + 730 days = Feb 27.)

---

EDIT:

Note that in the context of birthdays, people use "calendar years," not "unit of time which is ~1 revolution around the sun."

Birthdays aren't celebrated every X million seconds after the moment of birth.

They are celebrated the same day each calendar year -- notwithstanding the fuzzy concept of "same day" for incongruent calendar years. There's no singuar right answer, but that is the core question: "what is the same day next (calendar) year?"

[1] https://en.wikipedia.org/wiki/Begging_the_question

Re:Ask HN: Did you encounter any leap year bugs today? by quietbritishjim on Friday March 01, 2024 @03:43AM (#39559885)
> Feb 29 + 365 days = Feb 28.

Correct.

> And Feb 29 + 730 days = Feb 27

Incorrect. It's Feb 28 again. In a normal, non-leap year, if you add 365 days then you get back to the same date.

Re:Ask HN: Did you encounter any leap year bugs today? by paulddraper on Friday March 01, 2024 @11:01AM (#39563010)
Sorry, typo I meant that Feb 28 + 730 days = Feb 27 (sometimes)
Re:Ask HN: Did you encounter any leap year bugs today? by mark-r on Friday March 01, 2024 @08:21AM (#39561497)
> Birthdays aren't celebrated every X million seconds after the moment of birth.

As a surprise for a friend of mine, I threw him a gigasecond party on the day he turned 1000 million seconds old. Yes he was surprised, and a good time was had by all.

Re:Ask HN: Did you encounter any leap year bugs today? by azalazar on Friday March 01, 2024 @12:27PM (#39564160)
Many people say: Happy turn around the sun! and 365 is not the length of a year is the length of some years so, who knows... I'm against time zones and pro 28 days months and a couple of free days :D
Re:Ask HN: Did you encounter any leap year bugs today? by js2 on Saturday March 02, 2024 @06:29PM (#39576803)
> what is the same day next (calendar) year?"

When I wrote "+ 1 year" I meant year to represent 365 or 365.25 days, not "the same day next year.":

  >>> from datetime import date, timedelta
  >>> year = timedelta(days=365.25)
  >>> date(2024, 2, 29) + year
  datetime.date(2025, 2, 28)
You may have interpreted it as begging the question, but it was not my intent—though I admit my formulation was ambiguous.

> Note that in the context of birthdays, people use "calendar years," not "unit of time which is ~1 revolution around the sun."

You've never heard someone say they've celebrated another trip around the Sun? I literally have a photo from 2007 of my daughter in Montessori celebrating her birthday by holding a globe and walking around a candle representing the Sun. I think most people probably don't really think about whether it's a calendar year or astronomical year because for most people, they are usually equivalent and it doesn't matter.

But that's all beside the point. All I meant to point out is that I disagree that March is more logical. I don't think logic points us to one month or the other. You may feel March is more logical, but I don't accept your priors, so for me March is not more logical than February.

Re:Ask HN: Did you encounter any leap year bugs today? by Scarblac on Friday March 01, 2024 @02:23AM (#39559435)
Feb 28 is definitely too early, you haven't lived a whole year yet since your birthday. So March 1 it is. It's not your birthday but you can celebrate having made it another year.
Re:Ask HN: Did you encounter any leap year bugs today? by Jeema101 on Friday March 01, 2024 @09:32AM (#39562128)
Well 'year' can mean two different things though: 'calendar year' or 'solar year'.

Your calendar year birthday would be March 1 since one full calendar year has elapsed.

But Feb 28 is the nearest day to one full solar year, assuming you were born before about 6pm local time on Feb 29.

Two-day long birthday it is! :)

Re:Ask HN: Did you encounter any leap year bugs today? by usr1106 on Friday March 01, 2024 @02:05AM (#39559334)
Relevant question for driving, voting, marrying, drinking. I'd assume just the date is compared.

If you are born on 29th, on future 28th you are considered "too young", regardless whether a 29th exists or not. On future March 1st you are "old enough" again regardless.

If a 29th exists you are old enough already on that date. Drinking beer in Germany at 16, I guess in some countries at 20 could be relevant cases. For the more common minimum age of 18 for many things, the limit is reached always on March, 1st because a 29th cannot exist.