Skip to content

feat(dailyhoroscope): fix moon phase/sign on major phase event days#417

Merged
tavdog merged 1 commit intotronbyt:mainfrom
frame-shift:dailyhoroscope-fix
Mar 20, 2026
Merged

feat(dailyhoroscope): fix moon phase/sign on major phase event days#417
tavdog merged 1 commit intotronbyt:mainfrom
frame-shift:dailyhoroscope-fix

Conversation

@frame-shift
Copy link
Contributor

Astro-seek reports moon phase and sign for the exact event moment on New Moon/Full Moon/quarter days, not the calendar day. This caused wrong sign/phase display when the Moon changed signs after the event.

Fix: detect event timestamps, compute sign locally (using Meeus Ch 47 algorithms) and determine phase relative to noon UTC. Non-event days unchanged.

@frame-shift frame-shift requested a review from tavdog as a code owner March 19, 2026 20:08
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an inaccuracy in the daily horoscope applet where moon phase and sign were incorrectly displayed on days coinciding with major moon phase events. The previous method relied on an external source that reported values for the exact event moment, leading to discrepancies when the moon changed signs later in the day. The changes introduce a robust, local calculation method for these specific days, ensuring the displayed information accurately reflects the moon's state at noon UTC.

Highlights

  • Moon Phase and Sign Calculation Fix: Implemented a fix for incorrect moon phase and sign display on major moon phase event days (New Moon, Full Moon, Quarter Moons) in the daily horoscope applet.
  • Meeus Algorithms Integration: Introduced local calculation of moon phase and sign for event days, utilizing algorithms from Meeus Chapter 47, to ensure accuracy relative to noon UTC.
  • Version Update: Updated the applet version to 1.2 and documented the specific fix in the README.md.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces complex astronomical calculations to correct moon phase and sign data on major phase event days. My review focuses on improving the new code's readability and maintainability. I have suggested refactoring large data constants into a separate file and simplifying some of the new helper functions for clarity and efficiency.

Comment on lines +425 to +502
_ZODIAC_SIGNS = [
"aries",
"taurus",
"gemini",
"cancer",
"leo",
"virgo",
"libra",
"scorpio",
"sagittarius",
"capricorn",
"aquarius",
"pisces",
]

# Periodic terms for the moon longitude (Sigma-l) (Meeus Table 47.A)
# Each row: [D, M, M', F, coefficient (millionths of a degree)]
_MOON_LON_TERMS = [
[0, 0, 1, 0, 6288774],
[2, 0, -1, 0, 1274027],
[2, 0, 0, 0, 658314],
[0, 0, 2, 0, 213618],
[0, 1, 0, 0, -185116],
[0, 0, 0, 2, -114332],
[2, 0, -2, 0, 58793],
[2, -1, -1, 0, 57066],
[2, 0, 1, 0, 53322],
[2, -1, 0, 0, 45758],
[0, 1, -1, 0, -40923],
[1, 0, 0, 0, -34720],
[0, 1, 1, 0, -30383],
[2, 0, 0, -2, 15327],
[0, 0, 1, 2, -12528],
[0, 0, 1, -2, 10980],
[4, 0, -1, 0, 10675],
[0, 0, 3, 0, 10034],
[4, 0, -2, 0, 8548],
[2, 1, -1, 0, -7888],
[2, 1, 0, 0, -6766],
[1, 0, -1, 0, -5163],
[1, 1, 0, 0, 4987],
[2, -1, 1, 0, 4036],
[2, 0, 2, 0, 3994],
[4, 0, 0, 0, 3861],
[2, 0, -3, 0, 3665],
[0, 1, -2, 0, -2689],
[2, 0, -1, 2, -2602],
[2, -1, -2, 0, 2390],
[1, 0, 1, 0, -2348],
[2, -2, 0, 0, 2236],
[0, 1, 2, 0, -2120],
[0, 2, 0, 0, -2069],
[2, -2, -1, 0, 2048],
[2, 0, 1, -2, -1773],
[2, 0, 0, 2, -1595],
[4, -1, -1, 0, 1215],
[0, 0, 2, 2, -1110],
[3, 0, -1, 0, -892],
[2, 1, 1, 0, -810],
[4, -1, -2, 0, 759],
[0, 2, -1, 0, -713],
[2, 2, -1, 0, -700],
[2, 1, -2, 0, 691],
[2, -1, 0, -2, 596],
[4, 0, 1, 0, 549],
[0, 0, 4, 0, 537],
[4, -1, 0, 0, 520],
[1, 0, -2, 0, -487],
[2, 1, 0, -2, -399],
[0, 0, 2, -2, -381],
[1, 1, 1, 0, 351],
[3, 0, -2, 0, -340],
[4, 0, -3, 0, 330],
[2, -1, 2, 0, 327],
[0, 2, 1, 0, -323],
[1, 1, -1, 0, 299],
[2, 0, 3, 0, 294],
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve readability and maintainability, move the _ZODIAC_SIGNS and _MOON_LON_TERMS constants to a separate file (e.g., lunar_data.star) and load them. This aligns with the repository's general rule to keep large data structures out of the main application logic.

References
  1. To improve readability and maintainability, move large data structures into a separate file and load them into the main application logic.

Comment on lines +507 to +508
if d < 0:
d = d + 360.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This if block is redundant. In Starlark, the modulo operator % with a positive divisor ensures a non-negative result. d % 360.0 will always be in the range [0.0, 360.0), so this check can be removed.

Comment on lines +525 to +530
year = int(t.format("2006"))
month = int(t.format("1"))
day = int(t.format("2"))
hour = int(t.format("15"))
minute = int(t.format("4"))
second = int(t.format("5"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Instead of formatting the time object to a string and parsing components, access them directly via attributes like t.year, t.month, etc. This is more direct and readable.

Suggested change
year = int(t.format("2006"))
month = int(t.format("1"))
day = int(t.format("2"))
hour = int(t.format("15"))
minute = int(t.format("4"))
second = int(t.format("5"))
year = t.year
month = t.month
day = t.day
hour = t.hour
minute = t.minute
second = t.second

@frame-shift
Copy link
Contributor Author

I'm going to keep the code as is (and not adopt the Gemini suggestions) unless reviewers think otherwise :)

@tavdog tavdog merged commit 717dbbb into tronbyt:main Mar 20, 2026
1 check passed
@frame-shift frame-shift deleted the dailyhoroscope-fix branch March 20, 2026 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants