You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tested on python api v3.2.4, but haven't seen anything in 3.2.6 that would fix this.
When running the update function on a datetime field the return value is a string, rather than the datetime.datetime expected.
This string is also not compatible with plugging back in to further updates.
Example below;
importdatetimefromtank_vendor.shotgun_api3.lib.sgtimezoneimportUTCfromtank.utilimportshotgunutc_now=datetime.datetime.now(UTC())
sg=shotgun.create_sg_connection()
# update date field with utc date, returns as stringsg.update('PublishedFile', 433118, {'sg_accessed_at': utc_now})
>>> {'sg_accessed_at': '2020-11-27 09:52:29 UTC', 'type': 'PublishedFile', 'id': 433118}
# for comparison, find_one returns as datetime with tzinfosg.find_one('PublishedFile', [['id', 'is', 433118]], ['sg_accessed_at'])
>>> {'sg_accessed_at': datetime.datetime(2020, 11, 27, 9, 52, 29, tzinfo=<tank_vendor.shotgun_api3.lib.sgtimezone.LocalTimezoneobjectat0x7fdff227b8d0>), 'type': 'PublishedFile', 'id': 433118}
# plugging that string back into an update throws an errorsg.update('PublishedFile', 433118, {'sg_accessed_at': '2020-11-27 09:52:29 UTC'})
>>>Traceback (mostrecentcalllast):
File"<input>", line1, in<module>File"/TCP/home/spencere/toolkit_dev/install/core/python/tank_vendor/shotgun_api3/shotgun.py", line1435, inupdaterecord=self._call_rpc("update", params)
File"/TCP/home/spencere/toolkit_dev/install/core/python/tank_vendor/shotgun_api3/shotgun.py", line3314, in_call_rpcself._response_errors(response)
File"/TCP/home/spencere/toolkit_dev/install/core/python/tank_vendor/shotgun_api3/shotgun.py", line3619, in_response_errorsraiseFault(sg_response.get("message", "Unknown Error"))
Fault: Invaliddatetimeformat: 2020-11-2709:52:29UTC. Correctformatis2011-01-21T13:26:09Z (UTC) or2011-01-21T13:26:09-07:00 (UTCOffset)
# note, the recommended format also throws an errorsg.update('PublishedFile', 433118, {'sg_accessed_at': '2020-11-27T09:52:29Z (UTC)'})
>>>Traceback (mostrecentcalllast):
File"<input>", line1, in<module>File"/TCP/home/spencere/toolkit_dev/install/core/python/tank_vendor/shotgun_api3/shotgun.py", line1435, inupdaterecord=self._call_rpc("update", params)
File"/TCP/home/spencere/toolkit_dev/install/core/python/tank_vendor/shotgun_api3/shotgun.py", line3314, in_call_rpcself._response_errors(response)
File"/TCP/home/spencere/toolkit_dev/install/core/python/tank_vendor/shotgun_api3/shotgun.py", line3619, in_response_errorsraiseFault(sg_response.get("message", "Unknown Error"))
Fault: Invaliddatetimeformat: 2020-11-27T09:52:29Z (UTC). Correctformatis2011-01-21T13:26:09Z (UTC) or2011-01-21T13:26:09-07:00 (UTCOffset)
The text was updated successfully, but these errors were encountered:
Tested on python api v3.2.4, but haven't seen anything in 3.2.6 that would fix this.
When running the update function on a datetime field the return value is a string, rather than the datetime.datetime expected.
This string is also not compatible with plugging back in to further updates.
Example below;
The text was updated successfully, but these errors were encountered: