Ticket #10979: 10979-utils_tzinfo-r10651.patch

File 10979-utils_tzinfo-r10651.patch, 2.0 KB (added by George Song, 16 years ago)

Updated patch with additional fixes and tests

  • django/utils/tzinfo.py

     
    2020        else:
    2121            self.__offset = timedelta(minutes=offset)
    2222
    23         self.__name = u"%+03d%02d" % (offset / 60, offset % 60)
     23        sign = offset < 0 and '-' or '+'
     24        self.__name = u"%s%02d%02d" % (sign, abs(offset) / 60., abs(offset) % 60)
    2425
    2526    def __repr__(self):
    2627        return self.__name
  • tests/regressiontests/utils/tests.py

     
    99import timesince
    1010import datastructures
    1111import itercompat
     12import tzinfo
    1213from decorators import DecoratorFromMiddlewareTests
    1314
    1415# We need this because "datastructures" uses sorted() and the tests are run in
     
    2324    'timesince': timesince,
    2425    'datastructures': datastructures,
    2526    'itercompat': itercompat,
     27    'tzinfo': tzinfo,
    2628}
    2729
    2830class TestUtilsHtml(TestCase):
  • tests/regressiontests/utils/tzinfo.py

     
     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
     28if __name__ == "__main__":
     29    import doctest
     30    doctest.testmod()
Back to Top