3 ms·
Here's mine: https://git.sr.ht/~sircmpwn/meta.sr.ht/commit/e0be9dcd8e96f952547c243e078c47571f54fca2 https://git.sr.ht/~sircmpwn/meta.sr.ht/commit/e0be9dcd8e96f
by ddevault 7y ago
Here's mine:
https://git.sr.ht/~sircmpwn/meta.sr.ht/commit/e0be9dcd8e96f952547c243e078c47571f54fca2 https://git.sr.ht/~sircmpwn/meta.sr.ht/commit/e0be9dcd8e96f9...
- progval 7y agoI was about to ask why you didn't use a timedelta, and then found out that datetime.timedelta doesn't support anything greater than week. It also has this incorrect example: https://docs.python.org/3/library/datetime.html#examples-of-usage-timedelta https://docs.python.org/3/library/datetime.html#examples-of-...
- kgabbott 7y agoI respect wanting or needing to do this with just the builtin datetime module. For everyone else, I recommend relativedelta from the dateutil package: https://dateutil.readthedocs.io/en/stable/relativedelta.html https://dateutil.readthedocs.io/en/stable/relativedelta.html e.g.: >>> from dateutil.relativedelta import relativedelta >>> date = datetime.utcnow().date() >>> date datetime.date(2020, 2, 29) >>> date + relativedelta(years=1) datetime.date(2021, 2, 28)
- mj1586 7y agoI added to here: https://stackoverflow.com/a/60468711/634824 https://stackoverflow.com/a/60468711/634824 Thanks.