-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix observation events times with local time dates
Before, times from `Astronoby::Events::ObservationEvents` could produce wrong results when the location was far away from the Greenwich meridian. The reason was a bug when converting times (hour+minute+second) into `Time` objects. The date was correctly added by the time was in UTC. When converting back the UTC time to local time, the date could change. Now, the date is added depending on the time with concern of the user's UTC offset. The offset must be provided hen instantiating the `Astronoby::Observer` object using a new attribute: `#utc_offset`. ```rb utc_offset = "-05:00" time = Time.new(2015, 2, 5, 0, 0, 0, utc_offset) observer = Astronoby::Observer.new( latitude: Astronoby::Angle.from_degrees(38), longitude: Astronoby::Angle.from_degrees(-78), utc_offset: utc_offset ) sun = Astronoby::Sun.new(time: time) observation_events = sun.observation_events(observer: observer) observation_events.rising_time.getlocal(utc_offset) # => 2015-02-05 07:12:59 -0500 observation_events.transit_time.getlocal(utc_offset) # => 2015-02-05 12:25:59 -0500 observation_events.setting_time.getlocal(utc_offset) # => 2015-02-05 17:39:27 -0500 ```
- Loading branch information
1 parent
acfae17
commit d8fcb65
Showing
8 changed files
with
156 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.