Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
yen223
on March 1, 2024
|
parent
|
context
|
favorite
| on:
Ask HN: Did you encounter any leap year bugs today...
timedelta doesn't take "years" as a parameter, for the reasons others have listed here. It's ambiguous what subtracting by a year means, and there's no real sensible default either.
LeoPanthera
on March 1, 2024
[–]
relativedelta will do it:
from dateutil.relativedelta import relativedelta one_year = relativedelta(years=1)
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: