toastdriven/django-tastypie — pull request #939 by graup (2013-05-18 14:01:54+00:00)
Title: Adds iso-8601-strict to TASTYPIE_DATETIME_FORMATTING options

This is an improved patch for the issue raised here: https://github.com/toastdriven/django-tastypie/pull/460

This patch works by removing the microseconds from the datetime object by appliying a timedelta. Datetime objects without this information are automatically formated as expected (see http://docs.python.org/2/library/datetime.html#datetime.datetime.isoformat)

For time objects, first converts to a datetime to be able to apply timedeltas (see http://stackoverflow.com/questions/12448592/how-to-add-delta-to-python-datetime-time)

This way, timezone information is easily preserved.