'Test date/time conversion'

def testDateTime(self):

    assertEqual = self.assertEqual
    settings = current.deployment_settings
    session = current.session
    convert = S3TypeConverter._datetime
    settings.L10n.date_format = '%d.%m.%Y'
    settings.L10n.time_format = '%H.%M'
    result = convert('2011-10-01T16:37:00')
    assertEqual(result, datetime.datetime(2011, 10, 1, 16, 37, 0))
    result = convert('01.10.2011    16.37')
    assertEqual(result, datetime.datetime(2011, 10, 1, 16, 37, 0))
    settings.L10n.date_format = '%Y-%m-%d'
    settings.L10n.time_format = '%H:%M:S'
    session.s3.utc_offset = 0
    result = convert('2011-10-01    07:30:00')
    assertEqual(result, datetime.datetime(2011, 10, 1, 7, 30, 0))
    session.s3.utc_offset = (+ 11)
    result = convert('2011-10-01T22:00:00')
    assertEqual(result, datetime.datetime(2011, 10, 1, 11, 0, 0))
    result = convert('2011-10-01T09:00:00')
    assertEqual(result, datetime.datetime(2011, 9, 30, 22, 0, 0))
    result = convert('2011-10-01T09:00:00Z')
    assertEqual(result, datetime.datetime(2011, 10, 1, 9, 0, 0))
