Skip to content

Conversation

@vincentsarago
Copy link
Member

@vincentsarago vincentsarago commented Jan 14, 2025

ref #778

#778 (comment)

Maybe a Bug?

When user pass .000Z milliseconds in GET /search request, the ms part gets removed

@vincentsarago
Copy link
Member Author

This is all coming down to https://github.com/stac-utils/stac-fastapi/blob/6d655253182a031c1c0eb05268e7bb5df4a46726/stac_fastapi/types/stac_fastapi/types/rfc3339.py#L51C5-L92

rfc3339_str_to_datetime("2000-01-01T01:01:01.000Z")
>>> datetime.datetime(2000, 1, 1, 1, 1, 1, tzinfo=datetime.timezone.utc)

☝️ when we convert the datetime string to datetime, then the datetime has microseconds set to 0

Then when we convert the datetime back to string (in stac-fastapi-pgstac) we use .isoformat() method

datetime.datetime(2000, 1, 1, 1, 1, 1, 0, tzinfo=datetime.timezone.utc).isoformat().replace("+00:00", "Z")
>>> '2000-01-01T01:01:01Z'


datetime.datetime(2000, 1, 1, 1, 1, 1, 1, tzinfo=datetime.timezone.utc).isoformat().replace("+00:00", "Z")
>>> '2000-01-01T01:01:01.000001Z'

@vincentsarago
Copy link
Member Author

ahhhhhhh I knew this topic was familiar stac-utils/stac-pydantic#131 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants