'Test date conversion'

def testDate(self):

    assertEqual = self.assertEqual
    settings = current.deployment_settings
    session = current.session
    convert = S3TypeConverter._date
    settings.L10n.date_format = '%d.%m.%Y'
    result = convert('2011-10-01')
    assertEqual(result, datetime.date(2011, 10, 1))
    result = convert('01.10.2011')
    assertEqual(result, datetime.date(2011, 10, 1))
    session.s3.utc_offset = 0
    result = convert('2011-10-01')
    assertEqual(result, datetime.date(2011, 10, 1))
    session.s3.utc_offset = (+ 2)
    result = convert('2011-10-01')
    assertEqual(result, datetime.date(2011, 10, 1))
    result = convert('01.05.2015')
    assertEqual(result, datetime.date(2015, 5, 1))
    session.s3.utc_offset = (+ 11)
    result = convert('2011-10-01')
    assertEqual(result, datetime.date(2011, 9, 30))
    settings.L10n.date_format = '%Y-%m-%d'
    result = convert('2011-10-01T22:00:00')
    assertEqual(result, datetime.date(2011, 10, 1))
    result = convert('2011-10-01T09:00:00')
    assertEqual(result, datetime.date(2011, 9, 30))
    result = convert('2011-10-01T09:00:00Z')
    assertEqual(result, datetime.date(2011, 10, 1))
