def __new__(cls, value): dt = dates.parse_datetime(value) return datetime.datetime.__new__(cls, year=dt.year, month=dt.month, day=dt.day, hour=dt.hour, minute=dt.minute, second=dt.second, microsecond=dt.microsecond, tzinfo=dt.tzinfo)
def test_parse_datetime_none(self): parsed = dates.parse_datetime(None) self.assertEqual(parsed, None)
def test_parse_datetime(self): dtstr = '2015-04-02T16:44:30.423149+00:00' parsed = dates.parse_datetime(dtstr) self.assertEqual(dtstr, parsed.isoformat())
def from_dict(cls, action_dict): action = super(Action, cls).from_dict(action_dict) action.timestamp = parse_datetime(action.timestamp) return action
def test_parse_datetime(self): dtstr = "2015-04-02T16:44:30.423149+00:00" parsed = dates.parse_datetime(dtstr) self.assertEqual(dtstr, parsed.isoformat())