Opened 3 years ago

Closed 3 years ago

#27637 closed Bug (fixed)

timeuntil, timesince breaks in leap year edge case

Reported by: felixxm 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 felixxm 3 years ago.

Download all attachments as: .zip

Change History (15)

Changed 3 years ago by felixxm

Attachment: 27637.diff added

comment:1 Changed 3 years ago by Tim Graham

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 Changed 3 years ago by felixxm

Has patch: set

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

Resolution: fixed
Status: assignedclosed

In 3e5c5e6:

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

comment:4 Changed 3 years ago by Tim Graham <timograham@…>

In 25e82226:

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

Backport of 3e5c5e6754648590e87725b66d11d283079728e6 from master

comment:5 Changed 3 years ago by Tim Graham <timograham@…>

In 50830aa1:

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

Backport of 3e5c5e6754648590e87725b66d11d283079728e6 from master

comment:6 Changed 3 years ago by Tim Graham

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 Changed 3 years ago by felixxm

Status: newassigned

comment:8 Changed 3 years ago by vinay karanam

Owner: changed from felixxm to vinay karanam

comment:9 Changed 3 years ago by felixxm

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

comment:10 Changed 3 years ago by vinay karanam

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 Changed 3 years ago by Tim Graham <timograham@…>

In 6128c173:

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

comment:12 Changed 3 years ago by Tim Graham <timograham@…>

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 Changed 3 years ago by Tim Graham <timograham@…>

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 Changed 3 years ago by Tim Graham

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