Updated years_from_now to not blow up on leap days - #95
Conversation
|
Just noticed Travis isn't happy with these changes. I looked at the error logs and not sure if its grumpiness is due to these changes or something else. If you cool with this PR, do let me know what I need to do to make Travis happy again, so I can fix before merging |
|
Thank you for the pull request and sorry for that bug! Looks like the CI failure is just a Travis thing. I restarted it, let’s see if it is happier now. That said, I m wondering if adding |
Sure, I would incorporate your feedback. Hopefully by this evening. |
|
Also was not sure if February 28 should be the date, a year from a leap day, or March 1st. Not sure what the general practice is. Any thoughts? |
|
I suspect you can argue forever about that. We should probably just pick one, document it, and move on. If someone needs fine-grained control, they can always write their own version. |
|
Cool. I'll stick with Feb. 28 |
|
Not sure what’s up with Travis. I think you can ignore it for now. |
Ok, no problem.
By the way, we can't always reset to Feb. 28 when we get Feb. 29, since, if the resulting year is indeed a leap year, then we need to keep it at Feb. 29. 'Would keep all these in mind when I revisit the PR |
|
Strictly speaking you are right, but I think to keep the code simple, it is probably fine to just flip to the 28 always and be done. This is enough of a corner case to just document the behaviour. |
Done. |
|
Looks good now. Thank you for debugging and fixing! |
Tried to start Krill just now and got a panic message:
Found the cause to be due to the implementation of
Time::years_from_nowwhich was simply adding the numeric value of years to the current year. Things go wrong if this is done on a leap day, for example adding 1 year today would give2021-02-29which is invalid since 2021 is not a leap year.This PR seeks to fix that. It calculates the next years by adding 365 days. This means a year from a leap day would now result to February 28.