DateTime gotchas


Now that we have Date, Time and DateTime in apistar with 0.4, here’s a gotcha that I spent way too long looking at.

If you have a DateTime property, be aware of the following things:

  • obj.dateTimeProperty will be the raw datetime
  • str(obj.dateTimeProperty) will be a string as applied to the raw datetime. i.e. `2018-01-01 00:00:00’
  • dict(obj)[‘dateTimeProperty’] will be a string as generated by apistar.formats.DateTimeFormat.to_string() i.e. 2018-01-01T00:00:00Z


this is documented in under the Formats header