def tostr(dt): date = iso8601.parse(dt) return iso8601.tostring(date)
def test_tostring(self): dt = iso8601.parse('1998-06-13T14:12Z') self.assertEqual(iso8601.tostring(dt), '1998-06-13T14:12Z') self.assertEqual(iso8601.tostring(dt, 'Z'), '1998-06-13T14:12Z') self.assertEqual(iso8601.tostring(dt, '-05:00'), '1998-06-13T09:12-05:00')