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

shows that ms are striped with =0 for GET request #779

Closed
wants to merge 2 commits into from

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.

1 participant