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
{{ message }}
Repository navigation
Adding durations with year or month components convert to weeks #751
I think the behavior you've encountered is intentional due to different operations for + between Duration objects and between DateTime and Duration. For Duration + Duration, both durations are converted to seconds, combined, and formed into a new Duration. But, when adding a Duration to a DateTime, it directly increases the DateTime components, like year, based on the duration's equivalent. To ensure consistency, especially with variable-length units like years, convert Duration to timedelta first:
Activity
tempookian commentedon Mar 22, 2024
I think the behavior you've encountered is intentional due to different operations for
+betweenDurationobjects and betweenDateTimeandDuration. ForDuration+Duration, both durations are converted to seconds, combined, and formed into a newDuration. But, when adding aDurationto aDateTime, it directly increases theDateTimecomponents, likeyear, based on the duration's equivalent. To ensure consistency, especially with variable-length units like years, convertDurationtotimedeltafirst: