'Test the reading of datetimes stored in the db'

def test_datetime(self):

    from calibre.utils.date import parse_date
    from calibre.db.tables import c_parse, UNDEFINED_DATE, _c_speedup
    for raw in (u'2013-07-22    15:18:29+05:30', u'        2013-07-22    15:18:29+00:00', u'2013-07-22    15:18:29', u'2003-09-21    23:30:00-06:00'):
        self.assertTrue(_c_speedup(raw))
        ctime = c_parse(raw)
        pytime = parse_date(raw, assume_utc=True)
        self.assertEqual(ctime, pytime)
    self.assertEqual(c_parse(2003).year, 2003)
    for x in (None, u'', u'abc'):
        self.assertEqual(UNDEFINED_DATE, c_parse(x))
