rhannequin / astronoby

Ruby library based on astronomy and astrometry books
https://dev.to/rhannequin/series/17782
MIT License
59 stars 2 forks source link

Change `Astronoby::Sun` constructor #64

Closed rhannequin closed 7 months ago

rhannequin commented 7 months ago

Before, Astronoby::Sun would expect an epoch (Float) key argument as initializer param.

Now, it expects a time (Time) argument.

This is more convenient because an epoch doesn't provide information about the observer's time zone. Time.new(1991, 3, 14, 6, 0, 0, "+10:00") and Time.utc(1991, 3, 13, 20, 0, 0) are the same instant in time, and are converted to the same Julian Day, but they do not represent the same day depending on if we consider the time zone. If a developer provides a local time with a time zone, they would expect to receive sunrise and sunset times from the given day, not the one represented from the time in UTC.

This change fixes this behaviour and includes two new tests to ensure the local day is preserved when the provided time is not in UTC.