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] Timezone conversion issue when creating an Instant from a python datetime #239

Open
northshaur opened this issue Apr 18, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@northshaur
Copy link

Describe the bug
A clear and concise description of what the bug is. Describe if the bug appears in the cpp code, in the bindings, if it affects the unit tests, the compilation steps. Provide the versions of the library that are used in your setup or the hash of the images used (if any).

Steps to reproduce

  • Set system time to a time zone other than UTC, run the following code block
  • note how ostk_instant has an unexpected offset from the utc datetime object even when printed with utc time
import datetime
from ostk.physics.time import  Instant, Interval, Scale
from ostk.physics.time import DateTime
dt = datetime.datetime(2024, 4, 19, 0, 0, 0, tzinfo=datetime.timezone.utc)
ostk_instant = Instant.date_time(dt, Scale.UTC)

print(dt)
print(dt.astimezone(tz=datetime.timezone.utc))
print(ostk_instant.to_string(Scale.TT))
print(ostk_instant.to_string(Scale.UTC))

Example output of the bug:
image

Don't hesitate to add screenshots if that helps.

Expected behavior
image

Additional context
Setting system time to UTC fixes the issue

Potential suggestion
Issue is likely here (from Lucas) https://github.com/open-space-collective/open-space-toolkit-physics/blob/main/bindings/python/src/OpenSpaceToolkitPhysicsPy/Time/DateTime.cpp#L79

@northshaur northshaur added the bug Something isn't working label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant