'Test S3Calendar.parse_datetime'

def testDateTimeParsing(self):

    c = S3Calendar('Nepali')
    parse = c.parse_datetime
    assertEqual = self.assertEqual
    dtstr = '1982-08-06T13:01:41'
    dt = parse(dtstr)
    assertEqual(dt, datetime.datetime(1925, 11, 21, 13, 1, 41))
    settings = current.deployment_settings
    date_format = settings.get_L10n_date_format()
    time_format = settings.get_L10n_time_format()
    try:
        settings.L10n.date_format = '%d/%m/%Y'
        settings.L10n.time_format = '%H.%M'
        dtstr = '09/05/2021    13.21'
        dt = parse(dtstr, local=True)
        assertEqual(dt, datetime.datetime(1964, 8, 24, 13, 21, 0))
    finally:
        settings.L10n.date_format = date_format
        settings.L10n.time_format = time_format
    dtstr = '25.Paush    2060    10:13:44'
    dt = parse(dtstr, dtfmt='%d.%B    %Y    %H:%M:%S')
    assertEqual(dt, datetime.datetime(2004, 1, 9, 10, 13, 44))
    try:
        settings.L10n.date_format = '%d/%m/%Y'
        settings.L10n.time_format = '%H.%M'
        dt = parse(dtstr, dtfmt='%d.%B    %Y    %H:%M:%S', local=True)
        assertEqual(dt, datetime.datetime(2004, 1, 9, 10, 13, 44))
    finally:
        settings.L10n.date_format = date_format
        settings.L10n.time_format = time_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)
