Opened 7 years ago

Closed 7 years ago

#8080 closed (invalid)

Odd behavior in timesince and timeuntil methods

Reported by: jcarbaugh Owned by: nobody
Component: Template system Version: master
Severity: Keywords: timeuntil, timesince
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


This issue was raised while fixing #7201.

The timesince and timeuntil methods exhibit odd behavior if two arguments are passed and only one has tzinfo. Prior to #7201, the tzinfo of the first argument would be given to the second argument. This would cause the correct tzinfo of the second argument to be overwritten and the incorrect value returned from the method.

The fix for #7201 maintains this behavior but extends it so that if only one argument has tzinfo it will be applied to the argument without tzinfo. tzinfo will not be overwritten if null. The behavior was maintained because it would be backwards incompatible if changed.

This raises the issue of whether any timezone should be assumed or if an error should be raised. Python would normally throw a TypeError when operating on offset-naive and offset-aware datetimes. It seems as if the methods should allow the TypeError to be raised rather than making a timezone assumption.

Change History (1)

comment:1 Changed 7 years ago by jcarbaugh

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

Updated patch to #7201 resolves this issue.

Note: See TracTickets for help on using tickets.
Back to Top