Fixed #10979 -- Fixed misleading FixedOffset.__repr__(). Thanks, gsong
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12164 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
ddd6f28cac
commit
a7dc2c0653
|
@ -13,7 +13,8 @@ class FixedOffset(tzinfo):
|
||||||
else:
|
else:
|
||||||
self.__offset = timedelta(minutes=offset)
|
self.__offset = timedelta(minutes=offset)
|
||||||
|
|
||||||
self.__name = u"%+03d%02d" % (offset / 60, offset % 60)
|
sign = offset < 0 and '-' or '+'
|
||||||
|
self.__name = u"%s%02d%02d" % (sign, abs(offset) / 60., abs(offset) % 60)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return self.__name
|
return self.__name
|
||||||
|
|
|
@ -10,6 +10,7 @@ from django.utils.functional import SimpleLazyObject
|
||||||
import timesince
|
import timesince
|
||||||
import datastructures
|
import datastructures
|
||||||
import itercompat
|
import itercompat
|
||||||
|
import tzinfo
|
||||||
|
|
||||||
from decorators import DecoratorFromMiddlewareTests
|
from decorators import DecoratorFromMiddlewareTests
|
||||||
from functional import FunctionalTestCase
|
from functional import FunctionalTestCase
|
||||||
|
@ -26,6 +27,7 @@ __test__ = {
|
||||||
'timesince': timesince,
|
'timesince': timesince,
|
||||||
'datastructures': datastructures,
|
'datastructures': datastructures,
|
||||||
'itercompat': itercompat,
|
'itercompat': itercompat,
|
||||||
|
'tzinfo': tzinfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
from dateformat import *
|
from dateformat import *
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
"""
|
||||||
|
>>> from django.utils.tzinfo import FixedOffset
|
||||||
|
|
||||||
|
>>> FixedOffset(0)
|
||||||
|
+0000
|
||||||
|
>>> FixedOffset(60)
|
||||||
|
+0100
|
||||||
|
>>> FixedOffset(-60)
|
||||||
|
-0100
|
||||||
|
>>> FixedOffset(280)
|
||||||
|
+0440
|
||||||
|
>>> FixedOffset(-280)
|
||||||
|
-0440
|
||||||
|
>>> FixedOffset(-78.4)
|
||||||
|
-0118
|
||||||
|
>>> FixedOffset(78.4)
|
||||||
|
+0118
|
||||||
|
>>> FixedOffset(-5.5*60)
|
||||||
|
-0530
|
||||||
|
>>> FixedOffset(5.5*60)
|
||||||
|
+0530
|
||||||
|
>>> FixedOffset(-.5*60)
|
||||||
|
-0030
|
||||||
|
>>> FixedOffset(.5*60)
|
||||||
|
+0030
|
||||||
|
"""
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
import doctest
|
||||||
|
doctest.testmod()
|
Loading…
Reference in New Issue