def test_to_datetime(self): self.assertEquals(to_datetime('March 4, 2011 20:00', '%B %d, %Y %H:%S'), datetime.datetime(2011, 3, 4, 20, 0)) # test no year in parse format test_date = to_datetime('March 4, 20:00', '%B %d, %H:%S') self.assertEquals(test_date.year, datetime.datetime.utcnow().year) # test parse only date self.assertEquals(to_datetime('March 4, 2011', '%B %d, %Y'), datetime.datetime(2011, 3, 4))
def test_localized_to_datetime(self): current_locale = locale.getlocale(locale.LC_TIME) self.assertEquals( to_datetime('11 janvier 2011', '%d %B %Y', locale='fr_FR.UTF-8'), datetime.datetime(2011, 1, 11)) self.assertEquals(current_locale, locale.getlocale(locale.LC_TIME))
def test_localized_to_datetime(self): current_locale = locale.getlocale(locale.LC_ALL) self.assertEquals( to_datetime('11 janvier 2011', '%d %B %Y', locale='fr_FR.UTF-8'), datetime.datetime(2011, 1, 11) ) self.assertEquals(current_locale, locale.getlocale(locale.LC_ALL))