Opened 15 years ago

Closed 14 years ago

#10979 closed (fixed)

FixedOffset.__repr__ is misleading for negative offsets

Reported by: George Song Owned by: George Song
Component: Core (Other) Version: dev
Severity: Keywords: tzinfo
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If you pass a negative offset to FixedOffset, the tzinfo representation is misleading:

>>> from django.utils.tzinfo import FixedOffset
>>> tz = FixedOffset(-510)
>>> tz
-0930

The attached patch simply calculates the hours as a float, which yields the more correct representation.

>>> from django.utils.tzinfo import FixedOffset
>>> tz = FixedOffset(-510)
>>> tz
-0830

Attachments (2)

utils_tzinfo-r10651.patch (465 bytes ) - added by George Song 15 years ago.
10979-utils_tzinfo-r10651.patch (2.0 KB ) - added by George Song 15 years ago.
Updated patch with additional fixes and tests

Download all attachments as: .zip

Change History (7)

by George Song, 15 years ago

Attachment: utils_tzinfo-r10651.patch added

comment:1 by Malcolm Tredinnick, 15 years ago

Needs documentation: set
Needs tests: set
Triage Stage: UnreviewedAccepted

You appear to have left off the portion of the patch that changes the tests. :-)

by George Song, 15 years ago

Updated patch with additional fixes and tests

comment:2 by George Song, 15 years ago

Needs tests: unset
Owner: changed from nobody to George Song
Status: newassigned

Good call on the tests as I caught additional cases. I'm not sure what kind of documentation is needed as needs_docs is set to 1.

comment:3 by Malcolm Tredinnick, 15 years ago

Needs documentation: unset

The needs_docs was me being retarded. I was only to set needs_better_patch in that column.

comment:4 by George Song, 15 years ago

Triage Stage: AcceptedReady for checkin

comment:5 by Adrian Holovaty, 14 years ago

Resolution: fixed
Status: assignedclosed

(In [12164]) Fixed #10979 -- Fixed misleading FixedOffset.repr(). Thanks, gsong

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