Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leap year date is breaking animal records #740

Closed
jgardynik opened this issue Feb 29, 2020 · 2 comments
Closed

Leap year date is breaking animal records #740

jgardynik opened this issue Feb 29, 2020 · 2 comments

Comments

@jgardynik
Copy link

jgardynik commented Feb 29, 2020

Python is throwing a "day is out of range for month" exception trying to subtract 1 year from 2020-02-29.

/usr/lib/sheltermanager3/i18n.py in subtract_years
if years == int(years): return date.replace( year = date.year - int(years))

date datetime.datetime(2020, 2, 29, 0, 0)
years 1

To Reproduce
Steps to reproduce the behavior:
On our system, I can go to any animal. Or rather I can't, because it breaks.

Expected behavior
It should load the animal.

Screenshots
Screenshot (38)

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Chrome
  • Version 80

Additional context
Server is running version 42 on Linux.

@jgardynik jgardynik changed the title Leap year date is breaking anima Leap year date is breaking animal records Feb 29, 2020
@jgardynik
Copy link
Author

jgardynik commented Feb 29, 2020

I did fix this by commenting out that line and letting it fall through to the full timedelta function below. Not sure if that optimization is really necessary when it breaks on leap years.

@bobintetley
Copy link
Owner

bobintetley commented Feb 29, 2020

See this patch: 36c6841

It's not totally necessary but can lead to the addition or subtraction of a day when adding a year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants