Code

Opened 5 years ago

Closed 4 years ago

#10979 closed (fixed)

FixedOffset.__repr__ is misleading for negative offsets

Reported by: gsong Owned by: gsong
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 gsong 5 years ago.
10979-utils_tzinfo-r10651.patch (2.0 KB) - added by gsong 5 years ago.
Updated patch with additional fixes and tests

Download all attachments as: .zip

Change History (7)

Changed 5 years ago by gsong

comment:1 Changed 5 years ago by mtredinnick

  • Needs documentation set
  • Needs tests set
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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

Changed 5 years ago by gsong

Updated patch with additional fixes and tests

comment:2 Changed 5 years ago by gsong

  • Needs tests unset
  • Owner changed from nobody to gsong
  • Status changed from new to assigned

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 5 years ago by mtredinnick

  • Needs documentation unset

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

comment:4 Changed 5 years ago by gsong

  • Triage Stage changed from Accepted to Ready for checkin

comment:5 Changed 4 years ago by adrian

  • Resolution set to fixed
  • Status changed from assigned to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.