-
-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
in_months() returns wrong values in some cases in January to February #790
Comments
@sdispater @Secrus before we look for potential changes in the code, it should be clear what The output is what From the issue above:
This example should clarify the issue (let's assume we're dealing with a non-leap year):
So far so good. But what
The
By increasing the Clearly, it's not straightforward to establish what the output should be—all solutions appear to yield non-intuitive results. TL;DRAs Dijkstra advocated, the best solution appears to be to use a semi-open interval
There is only ever a The output is intuitive, consistent and hence also easy to document. I think using a semi-open interval should be the de facto choice for diffs/durations/ranges/intervals. Related issue: #606 |
Issue
We encountered a bug in 2.1 that persists in 3.0 when using the
in_months()
function of an interval where we get weird results for very specific dates. Examples are shown below.In a leap year (2024). Why would January 3rd return 1 but the 2rd and 4th return 0?
Not a leap year. Why would January 4th return 1 but the 3rd and 5th return 0?
The text was updated successfully, but these errors were encountered: