Live data from Hacker News

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

news.ycombinator.com

291–300 of 498 posts

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

#291
post #151

Earlier quoted context omitted.

It wasn't. https://learn.microsoft.com/sl-SI/office/troubleshoot/excel/...

Crikey - more helpful to me is the page linked from there - https://learn.microsoft.com/sl-SI/office/troubleshoot/excel/... > However, there is still a small error that must be accounted for. To eliminate this error, the Gregorian calendar stipulates that a year that is evenly divisible by 100 (for example, 1900) is a leap year only if it is also evenly divisible by 400. > For this reason, the following years are not…

"We establish that a bissextile [366th day] shall be inserted every four years (as with the present custom), except in centennial years. So the years 1700, 1800, and 1900 will not be leap years. Assuredly, the year 2000 will have an extra day in it." -- Greg XIII, 1582

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

#294

One thing I have learned from HN is that datetime issues are hard, prolific, programming language agnostic, and not to trust myself to get the logic right. (The same applies to floats.)

Another thing programmers should know and fix is that most of it is self-inflicted. When there’s no easy way to add a day, people add 86400000 and stumble upon a leap second. When time is not needed, they use fixed hours and fail at timezones. And so on. Most date libraries provide mostly trivial and at the same time low-level use-cases, so people do all the stupid math with what essentially is an irregularly-based number.

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

#296
post #33

No, but some of our software writes data to rotating directories named after the date, and while doing some manual debugging on a test system, it started failing to create these directories the first time it rotated on Feb 29 UTC. Turns out it just happened to run out of disk space at that time, but I had myself convinced that it was a leap year bug for over an hour. :)

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

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

#297

I wear Xiaomi's Amazfit Pro 3R. Digital. Wrist band. Hung at midnight of 29th Feb today. Did a bunch of factory reset but didn't recover. And then recovered at the morning of 1st of March. Date is relatively simple. days_in_month(year, month) : if(month==2) return days_in_feb(year) //all other months have constant number of days, always. days_in_feb(year,month) : if(!(year % 400)) return 29; if(!(year % 100)) return…

your function returns 29 days for every year not divisible by 400

!(x % y) is the same as (x % y == 0), which means the remainder is zero, so x is divisible by y.

So it returns 29 if divisible by 400, 28 if divisible by 100, etc.

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

#298
post #284
post #276

Earlier quoted context omitted.

What’s the significance of 365? Each Earth year has just a smidge under 365.25 days.

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…

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?

#299
post #289
post #270

Earlier quoted context omitted.

> If you plug your query into https://platform.openai.com/tokenizer , you can see that"egregious" is a single token That says it's 3 tokens.

It doesn’t even matter how many tokens there is, because LLMs are completely ignorant about how their input is structured. They don’t see letters or syllables cause they have no “eyes”. The closest analogy with a human is that vocal-ish concepts just emerge in their mind without any visual representation. They can only “recall” how many “e”s are there, but cannot look and count.

Pre-cogs, I knew it.

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

#300
post #268

Earlier quoted context omitted.

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

Is March more logical? Feb 29 + 1 year = Feb 28.

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.

Post reply on HN