Ask HN: Did you encounter any leap year bugs today?
41–50 of 498 posts
Re: Ask HN: Did you encounter any leap year bugs today?
#42The Casio F-91W doesn’t account for the year, it showed today’s date as Thursday, March 1st.
Re: Ask HN: Did you encounter any leap year bugs today?
#43Earlier quoted context omitted.
What is your definition of "subtracting a year"? Seems like that's a relatively ambiguous operation without more specification.
Since they mentioned a clean up script, I assume they could easily just use 365 days for that use case.
Re: Ask HN: Did you encounter any leap year bugs today?
#44Re: Ask HN: Did you encounter any leap year bugs today?
#45Re: Ask HN: Did you encounter any leap year bugs today?
#46Python. cls = , data_string = 'Feb 29 04:55:03.687' format = '%b %d %H:%M:%S.%f' E ValueError: day is out of range for month
Re: Ask HN: Did you encounter any leap year bugs today?
#47One cleanup script broke because Python doesn’t have a clean way to subtract a year, and if you do now.replace(year=now.year-1), you get a ValueError when now is 2/29. It’s easy enough to address. There are various StackOverflow posts on such things. Here is one: https://stackoverflow.com/questions/54394327/using-datetime-...
It's not that python doesn't have a clean way to subtract a year, it's that "subtract a year" is imprecise. There's a clean way to subtract 365 days, and there's a clean way to set the year one year earlier. But if you're doing the second thing, is python supposed to silently change to March 1 when you change the year from a leap day? There's no way around handling edge cases.
Re: Ask HN: Did you encounter any leap year bugs today?
#48Re: Ask HN: Did you encounter any leap year bugs today?
#49Python. cls = , data_string = 'Feb 29 04:55:03.687' format = '%b %d %H:%M:%S.%f' E ValueError: day is out of range for month
The confusing part, to me, is that Python would consider the above string to be parsed into a date in the first place, given that it has no year.