Skip to content
Open
Show file tree
Hide file tree
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 @@ -25,6 +25,11 @@ def parse_rfc3339(date_str: str) -> datetime:
"%Y-%m-%dT%H:%M:%SZ",
"%Y-%m-%dT%H:%M:%S.%fZ"
]

# %f accepts at most 6 fractional digits, but Rust can emit up to 9 (nanoseconds)
head, dot, fraction = date_str.partition(".")
if dot and fraction.endswith("Z"):
date_str = f"{head}.{fraction[:-1][:6]}Z"

for fmt in date_formats:
try:
Expand Down
5 changes: 5 additions & 0 deletions core/data/tests/test_serde_iso8601/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def parse_rfc3339(date_str: str) -> datetime:
"%Y-%m-%dT%H:%M:%SZ",
"%Y-%m-%dT%H:%M:%S.%fZ"
]

# %f accepts at most 6 fractional digits, but Rust can emit up to 9 (nanoseconds)
head, dot, fraction = date_str.partition(".")
if dot and fraction.endswith("Z"):
date_str = f"{head}.{fraction[:-1][:6]}Z"

for fmt in date_formats:
try:
Expand Down
5 changes: 5 additions & 0 deletions core/src/language/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,11 @@ fn json_translation_for_type(python_type: &str) -> Option<CustomJsonTranslationF
"%Y-%m-%dT%H:%M:%SZ",
"%Y-%m-%dT%H:%M:%S.%fZ"
]

# %f accepts at most 6 fractional digits, but Rust can emit up to 9 (nanoseconds)
head, dot, fraction = date_str.partition(".")
if dot and fraction.endswith("Z"):
date_str = f"{head}.{fraction[:-1][:6]}Z"

for fmt in date_formats:
try:
Expand Down