DateTime gotchas


#1

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

#2

this is documented in http://www.encode.io/apistar/api-guide/type-system/ under the Formats header