Opened 8 years ago

Closed 8 years ago

#27637 closed Bug (fixed)

timeuntil, timesince breaks in leap year edge case

Reported by: Mariusz Felisiak Owned by: vinay karanam
Component: Utilities Version: 1.9
Severity: Release blocker Keywords: timeuntil timesince
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

django.utils.timesince.timesince and django.utils.timesince.timeuntil breaks in leap year edge case. Bug appeared after 6700c909358d2ff9ff96f28dbc549906d8d32206. If we take two dates from different years where one of them is leap and leap day is not between days gap then timeuntil returns incorrect result e.g.

timeuntil(datetime.date(2016, 12, 25), datetime.date(2017, 1, 1))

returns 1 week, 1 day != 1 week.

Attachments (1)

27637.diff (732 bytes ) - added by Mariusz Felisiak 8 years ago.

Download all attachments as: .zip

Change History (15)

by Mariusz Felisiak, 8 years ago

Attachment: 27637.diff added

comment:1 by Tim Graham, 8 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted
Version: master1.9

Marking as a release blocker because there are timeuntil test failures that must be fixed on the 1.10 and 1.9 branches, whether that's by fixing the regression or by fixing the tests so they're not dependent on the day in which they run. The latter is probably better for 1.9.x since it's only receiving security fixes at this time.

comment:2 by Mariusz Felisiak, 8 years ago

Has patch: set

comment:3 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In 3e5c5e6:

Fixed #27637 -- Fixed timesince, timeuntil in leap year edge case.

comment:4 by Tim Graham <timograham@…>, 8 years ago

In 25e82226:

[1.10.x] Fixed #27637 -- Fixed timesince, timeuntil in leap year edge case.

Backport of 3e5c5e6754648590e87725b66d11d283079728e6 from master

comment:5 by Tim Graham <timograham@…>, 8 years ago

In 50830aa1:

[1.9.x] Fixed #27637 -- Fixed timesince, timeuntil in leap year edge case.

Backport of 3e5c5e6754648590e87725b66d11d283079728e6 from master

comment:6 by Tim Graham, 8 years ago

Has patch: unset
Resolution: fixed
Status: closednew

There's still a regression on the last day of a leap year (I think). Here's the failure:

======================================================================
FAIL [0.001s]: test_date_objects (utils_tests.test_timesince.TimesinceTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jenkins/workspace/pull-requests-trusty/database/sqlite3/label/trusty-pr/python/python2.7/tests/utils_tests/test_timesince.py", line 98, in test_date_objects
    self.assertEqual(timesince(today + self.oneday), '0\xa0minutes')
AssertionError: u'9\xa0hours, 56\xa0minutes' != u'0\xa0minutes'
- 9\xa0hours, 56\xa0minutes
+ 0\xa0minutes

comment:7 by Mariusz Felisiak, 8 years ago

Status: newassigned

comment:8 by vinay karanam, 8 years ago

Owner: changed from Mariusz Felisiak to vinay karanam

comment:9 by Mariusz Felisiak, 8 years ago

I think that you shouldn't reassigned ticket if someone else is working on it.

comment:10 by vinay karanam, 8 years ago

Sorry for that.
I just wanted you to be aware that I have already raised a PR for the fix.
I waited for an hour after raising the PR to modify the ticket.

comment:11 by Tim Graham <timograham@…>, 8 years ago

In 6128c173:

Refs #27637 -- Fixed timesince, timeuntil on New Year's Eve in a leap year.

comment:12 by Tim Graham <timograham@…>, 8 years ago

In b0eee991:

[1.10.x] Refs #27637 -- Fixed timesince, timeuntil on New Year's Eve in a leap year.

Backport of 6128c1736de98d8ab22829184409731b030cbff5 from master

comment:13 by Tim Graham <timograham@…>, 8 years ago

In 589a091b:

[1.9.x] Refs #27637 -- Fixed timesince, timeuntil on New Year's Eve in a leap year.

Backport of 6128c1736de98d8ab22829184409731b030cbff5 from master

comment:14 by Tim Graham, 8 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.
Back to Top