Live data from Hacker News

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

news.ycombinator.com

461–470 of 498 posts

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

#461
post #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 = datet…

In .NET there is an AddYears function that deals with all of this, and even gives you Feb 29 if the date is valid, otherwise Feb 28: https://learn.microsoft.com/en-us/dotnet/api/system.datetime...

Is it just me or does .NET have the most sane standard library for dealing with dates? Until you get into timezones that is

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

#462
post #268

Earlier quoted context omitted.

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

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…

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?

#464
post #118

Earlier quoted context omitted.

For the survalence records Telling base where, and when, you were

Shouldn't that just be a unix timestamp or something? You'd think resolving that to a date time could be done in the UI instead of in the business logic

I think I'd have used time-since-power-on; your infotainment system could take an RTC offset to get that to human dates.

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

#465
post #459
post #450

Earlier quoted context omitted.

I would think it's an edge case of correlation, but still correlation (100% of the time it has had this error, it was on a leap day, 0% of the time it was not)

It might appear as a correlation due to sampling error, but the two variables have no dependence with each other. There is no correlation with it being February 29 and the bug that was described.

I think that's exactly what OP is trying to say when they say 'correlation, not causation'. There is no causal link between 29th February and the bug, but they happened at the same time (were correlated, i.e. had the relationship that they happened at the same time).

This is a fairly typical informal usage of the word correlation in my experience, and while it might not be _technically correct_ (I don't know, I'm not an expert), it's an often enough used idiom.

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

#466
post #465
post #459

Earlier quoted context omitted.

It might appear as a correlation due to sampling error, but the two variables have no dependence with each other. There is no correlation with it being February 29 and the bug that was described.

I think that's exactly what OP is trying to say when they say 'correlation, not causation'. There is no causal link between 29th February and the bug, but they happened at the same time (were correlated, i.e. had the relationship that they happened at the same time). This is a fairly typical informal usage of the word correlation in my experience, and while it might not be _technically correct_ (I don't know, I'm not…

"Correlation does not equal causation" is a very important and pertinent concept in statistics, and I think we should aim to actually understand the concept instead of just trying to warp the meaning of the words to fit the example

The bug simply was not "a good example of correlation does not equal causation" as any statistician would use the phrase. That's my only point. OP is free to type whatever words he wants into the comment box and press send

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

#467

Earlier quoted context omitted.

The street lights use some sort of timer that's tracking dates? Don't they typically just use light sensors to know when to turn on? It seems to me that'd be a simpler solution and also provide light during solar eclipses, thick storms, etc.

First, these systems generally predate invention of semiconductor light sensors. Second, how much light you need is proportional to human activity, not only to darkness. At deep night artificial lighting should be minimal to save energy, minimise disturbance to nature and people's sleep, while during early morning when kids go to schools it should be maximal. Third, you need a central control over street lights anywa…

> Third, you need a central control over street lights anyway because you need to implement blackouts during wartime.

You heard of switches? Hell in our country with mandated rolling blackouts to prevent failure of the national electrical grid some sucker gets paid to drive around town every 2-3hours and flip a switch. Unrelated one municipality is failing to follow the mandate because they cannot afford said suckers overtime pay...

I also strongly believe well lit streets at all times are important, its better to try to limit the lights' bleed than it is to have darkness. One human killed or otherwise injured (rape/assault) due to bad lighting should be enough to say this is a bad idea.

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

#468

Remember, always use a library for cryptography, payments, and date calculations.

Yup. I use the datetime module in Python and didn’t need to do anything extra.

For JavaScript, it’s `date-fns` for me
Post reply on HN