Opened 16 years ago

Closed 16 years ago

#8080 closed (invalid)

Odd behavior in timesince and timeuntil methods

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

Description

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 by Jeremy Carbaugh, 16 years ago

Resolution: invalid
Status: newclosed

Updated patch to #7201 resolves this issue.

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