-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[astro] Fix timezone regression in moon phase calculation #21372
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |
|
|
||
| import java.time.InstantSource; | ||
| import java.time.ZoneId; | ||
| import java.time.ZoneOffset; | ||
| import java.util.Map; | ||
| import java.util.stream.Collectors; | ||
|
|
||
|
|
@@ -37,7 +38,9 @@ public static MoonPhaseSet calculate(InstantSource instantSource, double julianD | |
| final MoonPhaseSet result; | ||
|
|
||
| if (previousMP.needsRecalc(julianDate)) { | ||
| double julianDateMidnight = Math.floor(julianDate + 0.5) - 0.5; | ||
| ZoneOffset offset = zone instanceof ZoneOffset zo ? zo : zone.getRules().getOffset(instantSource.instant()); | ||
| double offsetDays = offset.getTotalSeconds() / 86400.0; | ||
| double julianDateMidnight = Math.floor(julianDate + offsetDays + 0.5) - 0.5 - offsetDays; | ||
| double parentNewMoon = getPhase(julianDateMidnight, MoonPhase.NEW, false); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Before #20104, midnight was used to find the remarkable phase dates for the local calendar day, while The existing test provides a deterministic example: it has the Amsterdam new moon on 2019-03-06 at 17:04, which also agrees with published astronomical phase tables. If this calculation runs at 18:00 that day,
Could the current lunation used for age be selected from |
||
|
|
||
| Map<MoonPhase, Double> comingPhases = MoonPhase.remarkables().stream() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point.