Opened 8 years ago

Closed 7 years ago

#10979 closed (fixed)

FixedOffset.__repr__ is misleading for negative offsets

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

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 8 years ago.
10979-utils_tzinfo-r10651.patch (2.0 KB) - added by George Song 8 years ago.
Updated patch with additional fixes and tests

Download all attachments as: .zip

Change History (7)

Changed 8 years ago by George Song

Attachment: utils_tzinfo-r10651.patch added

comment:1 Changed 8 years ago by Malcolm Tredinnick

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

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

Changed 8 years ago by George Song

Updated patch with additional fixes and tests

comment:2 Changed 8 years ago by George Song

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 Changed 8 years ago by Malcolm Tredinnick

Needs documentation: unset

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

comment:4 Changed 8 years ago by George Song

Triage Stage: AcceptedReady for checkin

comment:5 Changed 7 years ago by Adrian Holovaty

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