Skip to content

pystac.read_file returns temporal extents with tzinfo=tzlocal() depending on the environment. #819

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

Closed
TomAugspurger opened this issue Jun 3, 2022 · 0 comments · Fixed by #848
Assignees
Milestone

Comments

@TomAugspurger
Copy link
Collaborator

Depending on the environment (I think the value of TZ, maybe other things), the timezones on pystac Collections can be tzlocal rather than utc.

>>> pystac.read_file("https://planetarycomputer.microsoft.com/api/stac/v1/collections/sentinel-2-l2a").extent.temporal.intervals[0][0].tzinfo
tzlocal()

Here's a demonstration of the environment TZ influencing the output:

TZ=UTC python -c 'import pystac; print(pystac.read_file("https://planetarycomputer.microsoft.com/api/stac/v1/collections/sentinel-2-l2a").extent.temporal.intervals[0][0].tzinfo)'
tzlocal()TZ="US/Central" python -c 'import pystac; print(pystac.read_file("https://planetarycomputer.microsoft.com/api/stac/v1/collections/sentinel-2-l2a").extent.temporal.intervals[0][0].tzinfo)'
tzutc()

Since the STAC spec says that all datetimes should be UTC, I think that the datetimes should be tz-aware. If python-dateutil happens to return a tzlocal timezone, I think pystac can assume that local = UTC and localize it to UTC.

Upstream issue in python-dateutil: dateutil/dateutil#349

xref #760. I'm not sure if this would fix this behavior or not (cc. @philvarner)

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 a pull request may close this issue.

2 participants