astronoby icon indicating copy to clipboard operation
astronoby copied to clipboard

Possible incorrect date for Astronoby::Sun.observation_events.setting_time

Open trevorturk opened this issue 5 months ago • 2 comments

Description

Possible incorrect date for Astronoby::Sun.observation_events.setting_time.

Reproduction Steps

lat = 41.87
lon = -87.62
zone = "America/Chicago" # ActiveSupport::TimeZone
time = "2024-09-11 16:36:50 -0500" # ActiveSupport::TimeWithZone

observer = Astronoby::Observer.new(
  latitude: Astronoby::Angle.from_degrees(lat),
  longitude: Astronoby::Angle.from_degrees(lon),
)

sun = Astronoby::Sun.new(time: time)
events = sun.observation_events(observer: observer)

events.rising_time # 2024-09-11 11:27:07 UTC
events.setting_time # 2024-09-11 00:07:35 UTC (notice this time is before the rising time)

events.rising_time.in_time_zone(zone) # 2024-09-11 06:27:07 -0500
events.setting_time.in_time_zone(zone) # 2024-09-10 19:07:35 -0500 (notice this is the correct time, but one day too early)

Expected behavior

Expect setting_time to be after rising_time on the same date. I tested also with passing in a UTC time, but I believe (from a quick search in the issues) that I should be able to pass in a ActiveSupport::TimeWithZone?

Actual behavior

Actual setting_time is before rising_time on the day before (but is the correct hour/min/sec).

System configuration

astronoby version: astronoby (0.5.0) ruby version: ruby 3.3.5

Apologies if I'm misunderstanding something -- thank you for the help!

trevorturk avatar Sep 11 '24 22:09 trevorturk