Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix date parsing in Azure Table entities #16843

Closed
wants to merge 1 commit into from
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