'Test date+time parsing'

def testDateTimeParsing(self):

    assertEqual = self.assertEqual
    assertRaises = self.assertRaises
    now = current.request.utcnow
    test_dates = (('%Y-%m-%d    %H:%M:%S', '2009-04-16    13:54:20', (2009, 4, 16, 13, 54, 20)), ('%d.%m.%Y    %H:%M', '1.8.1936    15:38', (1936, 8, 1, 15, 38, 0)), ('%d/%m/%Y    %H:%M', None, 'TypeError'), ('%d/%m/%Y    %H:%M', '16/04/1678', 'ValueError'), ('%d/%m/%Y    %H:%M', '16/04/1678    23:59', (1678, 4, 16, 23, 59, 0)), ('%d/%m    %I:%M    %p', '16/04    12:30    am', (now.year, 4, 16, 0, 30, 0)), ('%d/%m    %I:%M    %p', '8/4    12:30    am', (now.year, 4, 8, 0, 30, 0)), ('%d-%b-%Y    %I:%M    %p', '31-Apr-2005    0:30am', (2005, 5, 1, 0, 30, 0)))
    c = S3Calendar('Gregorian')
    for (dtfmt, string, timetuple) in test_dates:
        parser = S3DateTimeParser(c, dtfmt)
        if (timetuple == 'ValueError'):
            with assertRaises(ValueError):
                result = parser.parse(string)
        elif (timetuple == 'TypeError'):
            with assertRaises(TypeError):
                result = parser.parse(string)
        else:
            result = parser.parse(string)
            assertEqual(result, timetuple)
