'Test S3Calendar.parse_date'

def testDateParsing(self):

    c = S3Calendar()
    parse = c.parse_date
    assertEqual = self.assertEqual
    dtstr = '1925-11-21'
    dt = parse(dtstr)
    assertEqual(dt, datetime.date(1925, 11, 21))
    settings = current.deployment_settings
    date_format = settings.get_L10n_date_format()
    try:
        settings.L10n.date_format = '%d/%m/%Y'
        dtstr = '08/05/1983'
        dt = parse(dtstr, local=True)
        assertEqual(dt, datetime.date(1983, 5, 8))
    finally:
        settings.L10n.date_format = date_format
    dtstr = '09.01.2004'
    dt = parse(dtstr, dtfmt='%d.%m.%Y')
    assertEqual(dt, datetime.date(2004, 1, 9))
    try:
        settings.L10n.date_format = '%d/%m/%Y'
        dt = parse(dtstr, dtfmt='%d.%m.%Y', local=True)
        assertEqual(dt, datetime.date(2004, 1, 9))
    finally:
        settings.L10n.date_format = date_format
    dtstr = None
    dt = parse(dtstr)
    assertEqual(dt, None)
    dtstr = 96
    dt = parse(dtstr)
    assertEqual(dt, None)
    dtstr = 'Invalid    Value'
    dt = parse(dtstr)
    assertEqual(dt, None)
