'Test datetime representation (timezone-aware)'

def testTZAwareDateTimeRepresent(self):

    session = current.session
    utc = dateutil.tz.tzutc()
    assertEqual = self.assertEqual
    represent = S3DateTime.datetime_represent
    utc_offset = session.s3.utc_offset
    try:
        dt = datetime.datetime(1973, 4, 21, 15, 30, 0, tzinfo=utc)
        session.s3.utc_offset = (+ 2)
        dtstr = represent(dt, utc=True)
        assertEqual(dtstr, '1973-04-21    17:30:00')
        dt = datetime.datetime(1993, 6, 17, 22, 0, 0, tzinfo=utc)
        session.s3.utc_offset = (+ 6)
        dtstr = represent(dt, utc=True)
        assertEqual(dtstr, '1993-06-18    04:00:00')
        dt = datetime.datetime(1995, 4, 1, 3, 0, 0, tzinfo=utc)
        session.s3.utc_offset = (-8)
        dtstr = represent(dt, utc=True)
        assertEqual(dtstr, '1995-03-31    19:00:00')
        dt = datetime.datetime(1995, 4, 1, 3, 0, 0, tzinfo=utc)
        session.s3.utc_offset = (-8)
        dtstr = represent(dt, utc=False)
        assertEqual(dtstr, '1995-04-01    03:00:00')
    finally:
        session.s3.utc_offset = utc_offset
