Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,12 @@ def tzname(self, dt):

def _from_entity_datetime(value):
# Cosmos returns this with a decimal point that throws an error on deserialization
if value[-9:] == ".0000000Z":
value = value[:-9] + "Z"
for suffix_len in (5, 9):
suffix = "." + ("0" * (suffix_len - 2)) + "Z"
if value[-suffix_len:] == suffix:
value = value[:-suffix_len] + "Z"
break

return datetime.datetime.strptime(value, "%Y-%m-%dT%H:%M:%SZ").replace(
tzinfo=Timezone()
)
Expand Down