Skip to content

feat(routes-f): moon phase calculator#954

Open
dmystical-coder wants to merge 1 commit into
StreamFi-x:devfrom
dmystical-coder:feat/791-moon-phase
Open

feat(routes-f): moon phase calculator#954
dmystical-coder wants to merge 1 commit into
StreamFi-x:devfrom
dmystical-coder:feat/791-moon-phase

Conversation

@dmystical-coder
Copy link
Copy Markdown
Contributor

Summary

Implements the moon phase calculator (#791).

GET /api/routes-f/moon-phase?date=YYYY-MM-DD{ phase_name, illumination_percent, age_days }

Approach

  • Documented synodic-month approximation: reference new moon epoch 2000-01-06 18:14 UTC and mean synodic month 29.53058867 days (Meeus, Astronomical Algorithms). Lunar age is the elapsed time since the epoch reduced modulo the synodic month.
  • Illumination = (1 − cos(2π·age/synodic)) / 2.
  • Eight phases (new, waxing crescent, first quarter, waxing gibbous, full, waning gibbous, last quarter, waning crescent) selected by nearest-eighth rounding so the principal phases sit on their exact ages.
  • Rejects malformed and impossible calendar dates (2024-02-30) via a component round-trip, since new Date(...) silently rolls overflow days into the next month.

Tests

Validated against NASA new moons (2024-01-11, 2025-01-29) and full moons (2024-01-25, 2025-01-13), plus epoch, half-cycle, a full eight-phase walk, range invariants, and the route's 400 paths.

Scope

All files live under app/api/routes-f/moon-phase/; the only import is the existing in-folder _lib/validate helper, matching the merged fiscal-quarter/deep-merge routes.

Closes #791

Add GET /api/routes-f/moon-phase?date=YYYY-MM-DD returning phase_name,
illumination_percent, and age_days using a documented synodic-month
approximation (reference new moon 2000-01-06 18:14 UTC, synodic month
29.53058867 days). Rejects impossible calendar dates via component
round-trip. Tested against known new/full moon dates.

Closes StreamFi-x#791
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 2, 2026

@dmystical-coder is attempting to deploy a commit to the david's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Jun 2, 2026

@dmystical-coder Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

feat(routes-f): moon phase calculator

1 participant