Created
August 2, 2019 11:52
-
-
Save mayhem/fbb0da414dc1fd1dd272d69b87122d9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import datetime | |
from dateutil.relativedelta import relativedelta | |
# 2019-08-02 | |
begin_date = datetime.datetime.utcnow() | |
def get_months(from_date, days): | |
date_pairs = [] | |
for offset in range(days + 1): | |
curr_date = from_date + relativedelta(days=-offset) | |
date_pairs.append((curr_date.year, curr_date.month)) | |
return tuple(set(date_pairs)) | |
print(get_months(begin_date, 50)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment