Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #10979 -- Fixed misleading FixedOffset.__repr__(). Thanks, gsong

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12164 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit a7dc2c06532586f8988d04d8f697c4ebfcabfde8 1 parent ddd6f28
Adrian Holovaty authored January 10, 2010
3  django/utils/tzinfo.py
@@ -13,7 +13,8 @@ def __init__(self, offset):
13 13
         else:
14 14
             self.__offset = timedelta(minutes=offset)
15 15
 
16  
-        self.__name = u"%+03d%02d" % (offset / 60, offset % 60)
  16
+        sign = offset < 0 and '-' or '+'
  17
+        self.__name = u"%s%02d%02d" % (sign, abs(offset) / 60., abs(offset) % 60)
17 18
 
18 19
     def __repr__(self):
19 20
         return self.__name
2  tests/regressiontests/utils/tests.py
@@ -10,6 +10,7 @@
10 10
 import timesince
11 11
 import datastructures
12 12
 import itercompat
  13
+import tzinfo
13 14
 
14 15
 from decorators import DecoratorFromMiddlewareTests
15 16
 from functional import FunctionalTestCase
@@ -26,6 +27,7 @@
26 27
     'timesince': timesince,
27 28
     'datastructures': datastructures,
28 29
     'itercompat': itercompat,
  30
+    'tzinfo': tzinfo,
29 31
 }
30 32
 
31 33
 from dateformat import *
30  tests/regressiontests/utils/tzinfo.py
... ...
@@ -0,0 +1,30 @@
  1
+"""
  2
+>>> from django.utils.tzinfo import FixedOffset
  3
+
  4
+>>> FixedOffset(0)
  5
++0000
  6
+>>> FixedOffset(60)
  7
++0100
  8
+>>> FixedOffset(-60)
  9
+-0100
  10
+>>> FixedOffset(280)
  11
++0440
  12
+>>> FixedOffset(-280)
  13
+-0440
  14
+>>> FixedOffset(-78.4)
  15
+-0118
  16
+>>> FixedOffset(78.4)
  17
++0118
  18
+>>> FixedOffset(-5.5*60)
  19
+-0530
  20
+>>> FixedOffset(5.5*60)
  21
++0530
  22
+>>> FixedOffset(-.5*60)
  23
+-0030
  24
+>>> FixedOffset(.5*60)
  25
++0030
  26
+"""
  27
+
  28
+if __name__ == "__main__":
  29
+    import doctest
  30
+    doctest.testmod()

0 notes on commit a7dc2c0

Please sign in to comment.
Something went wrong with that request. Please try again.