You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the issues of this repo and believe that this is not a duplicate.
OS version and name: MacOS 10.14 (running Python 3.7.2)
Pendulum version: 2.1.0
Issue
The duration methods duration.total_days() and duration.in_days() do not match expected results, and/or do not match the docs. Since the docs seem to show an inconsistent / incorrect result (specifically for duration.in_days()), it isn't clear what the real expected behavior is.
I was quite confused about the logic and differences between the conversion of years/months into days for a duration (still am), so I just re-created the example used in the docs in order to test my thinking. And when doing that, I got different results to what is shown in docs.
My results below, using exact example from Pendulum docs duration section:
# I copied example from pendulum docs>>>it=pendulum.duration(
... years=2, months=3,
... days=1177, seconds=7284, microseconds=1234
... )
>>>it.days1997# seems OK... 2 * 365 days/year + 3 * 30days/month + 1177 days = 1997>>>it.total_days()
1177.0843055698379# this matches result shown in docs (1177.084...)# but result seems counter-intuitive based on name of method# I would expect 'total_days' to be 1997.084... including days from years and months>>>it.in_days()
1177# this DOES NOT match result shown in docs (docs show 1997 for it.in_days())# but does match description of this method being truncated integer of total_days()
Based on description of duration.in_days() method in the docs, I would expect duration.total_days() and duration.in_days() to return same result, only with in_days() as a truncated integer as described. That's what I actually got, but doesn't match docs.
But larger issue seems to be that both .total_days() and .in_days() return incorrect (or at least un-intuitive) results -- I would expect them to both return 1997... in this case, including the days from years and months. (not 1177)
Seems like there is either:
A) Incorrect example in the docs (specifically where it shows return of 1997 for .in_days() method)
B) Bug in duration.in_days() and/or duration.total_days() method, especially when including years/months in duration
C) Both A and B
D)or I'm totally missing something...
This may be related to #387 but I'm creating this as separate bug because it seems there is at least a docs issue here, and because 387 relates to total_seconds() and maybe there are drop-in compatibility constraints with built-in total_seconds() method for that one?
Thanks to the creator & contributors!
The text was updated successfully, but these errors were encountered:
I am on the latest Pendulum version.
I have searched the issues of this repo and believe that this is not a duplicate.
OS version and name: MacOS 10.14 (running Python 3.7.2)
Pendulum version: 2.1.0
Issue
The duration methods duration.total_days() and duration.in_days() do not match expected results, and/or do not match the docs. Since the docs seem to show an inconsistent / incorrect result (specifically for duration.in_days()), it isn't clear what the real expected behavior is.
I was quite confused about the logic and differences between the conversion of years/months into days for a duration (still am), so I just re-created the example used in the docs in order to test my thinking. And when doing that, I got different results to what is shown in docs.
My results below, using exact example from Pendulum docs duration section:
Based on description of duration.in_days() method in the docs, I would expect duration.total_days() and duration.in_days() to return same result, only with in_days() as a truncated integer as described. That's what I actually got, but doesn't match docs.
But larger issue seems to be that both .total_days() and .in_days() return incorrect (or at least un-intuitive) results -- I would expect them to both return 1997... in this case, including the days from years and months. (not 1177)
Seems like there is either:
A) Incorrect example in the docs (specifically where it shows return of 1997 for .in_days() method)
B) Bug in duration.in_days() and/or duration.total_days() method, especially when including years/months in duration
C) Both A and B
D)or I'm totally missing something...
This may be related to #387 but I'm creating this as separate bug because it seems there is at least a docs issue here, and because 387 relates to total_seconds() and maybe there are drop-in compatibility constraints with built-in total_seconds() method for that one?
Thanks to the creator & contributors!
The text was updated successfully, but these errors were encountered: