arrow-py / arrow

🏹 Better dates & times for Python
https://arrow.readthedocs.io
Apache License 2.0
8.71k stars 673 forks source link

Range gives inconsistent results for month end #842

Closed jadchaar closed 4 years ago

jadchaar commented 4 years ago

Issue Description

env ❯ python3
Python 3.8.5 (default, Jul 21 2020, 10:48:26)
[Clang 11.0.3 (clang-1103.0.32.62)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import arrow
>>> from datetime import datetime
>>> start_date = datetime(2014, 12, 31)
>>> list(arrow.Arrow.range("month", start_date, limit=5))
[<Arrow [2014-12-31T00:00:00+00:00]>, <Arrow [2015-01-31T00:00:00+00:00]>, <Arrow [2015-02-28T00:00:00+00:00]>, <Arrow [2015-03-28T00:00:00+00:00]>, <Arrow [2015-04-28T00:00:00+00:00]>

When months in a range end on different dates (e.g. January and February), the range seems to continue with the end date of the previous month.

System Info

jadchaar commented 4 years ago

This issue may occur as well with years since leap years can increase the number of days in a year.

systemcatch commented 4 years ago

Fixed in #844