Get Moon Phase Dates by Month or Year

Call it

GET https://production-sfo.browserless.io/skills?token=TOKEN-HERE&domain=moongiant.com&task=get-moon-phase-dates

Summary

Retrieve dates and UTC times for the four principal moon phases from Moon Giant's monthly calendars. This skill was captured from a live agent session on moongiant.com and is published here as a reusable recipe for agents.

NoteSelectors and URL schemes drift as sites change. A skill is a snapshot of what worked when it was captured, not a contract. Agents re-learn it when it stops working.

SKILL.md

Retrieve the dates and UTC times of the four principal moon phases for a requested month or year.

Use Cases

Use to look up a new moon, first quarter, full moon, or last quarter in a particular month or year. Filter the extracted entries by phase or date if requested.

Automation Flow

  1. Build https://www.moongiant.com/moonphases/{month}/{year}/ with a lowercase English month name, such as august, and a four-digit year.
  2. Navigate directly to the URL, then run this evaluator on the loaded page:
(() => {
  const match = location.pathname.match(/^\/moonphases\/([a-z]+)\/(\d{4})\/?$/i);
  if (!match) return { month: null, year: null, phases: [] };
  const [, month, year] = match;
  const text = document.body.innerText.replace(/\s+/g, ' ');
  const phases = [...text.matchAll(/(New Moon|First Quarter|Full Moon|Last Quarter) ([A-Z][a-z]+ \d{1,2}) (\d{1,2}:\d{2} UTC)/g)]
    .map(([, phase, date, timeUtc]) => ({ phase, date: `${date}, ${year}`, timeUtc }));
  return { month, year: Number(year), phases: [...new Map(phases.map(p => [`${p.phase}|${p.date}`, p])).values()] };
})()
  1. For a whole year, run the evaluator for each of the 12 months and combine the phases arrays. Check that each page returned the requested month and year and a populated phase list before treating the result as complete.

Possible Friction Points

  • /phase/{phase}/{year}/ can return today's moon phase rather than a historical calendar. Use /moonphases/{month}/{year}/.
  • A phase can occur twice in one month. Keep entries with distinct dates, and preserve the displayed UTC times.

Example Result

{
  "month": "august",
  "year": 2023,
  "phases": [
    { "phase": "Full Moon", "date": "August 1, 2023", "timeUtc": "18:31 UTC" },
    { "phase": "Last Quarter", "date": "August 8, 2023", "timeUtc": "10:28 UTC" },
    { "phase": "New Moon", "date": "August 16, 2023", "timeUtc": "09:38 UTC" },
    { "phase": "First Quarter", "date": "August 24, 2023", "timeUtc": "09:57 UTC" },
    { "phase": "Full Moon", "date": "August 31, 2023", "timeUtc": "01:35 UTC" }
  ]
}