Skip to content
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

Full moon, new moon, first quarter, and last quarter too long #23

Open
nadiavanleur opened this issue Jul 12, 2022 · 3 comments
Open

Full moon, new moon, first quarter, and last quarter too long #23

nadiavanleur opened this issue Jul 12, 2022 · 3 comments

Comments

@nadiavanleur
Copy link

This plugin is telling me the moon phases in the title last 3 to 4 days. However, these phases only happen on one moment. While waning/waxing gibbous/crescent can last multiple days, the other phases cannot.

'2021-10-20': 'full',
  '2021-10-21': 'full',
  '2021-10-22': 'full',
  '2021-10-23': 'waning-gibbous',
  '2021-10-24': 'waning-gibbous',
  '2021-10-25': 'waning-gibbous',
  '2021-10-26': 'waning-gibbous',
  '2021-10-27': 'last-quarter',
  '2021-10-28': 'last-quarter',
  '2021-10-29': 'last-quarter',
  '2021-10-30': 'last-quarter',
  '2021-10-31': 'waning-crescent',
  '2021-11-01': 'waning-crescent',
  '2021-11-02': 'waning-crescent',
  '2021-11-03': 'waning-crescent',
  '2021-11-04': 'new',
  '2021-11-05': 'new',
  '2021-11-06': 'new',
  '2021-11-07': 'waxing-crescent',
  '2021-11-08': 'waxing-crescent',
  '2021-11-09': 'waxing-crescent',
  '2021-11-10': 'waxing-crescent',
  '2021-11-11': 'first-quarter',
  '2021-11-12': 'first-quarter',
  '2021-11-13': 'first-quarter',
  '2021-11-14': 'first-quarter',
  '2021-11-15': 'waxing-gibbous',
  '2021-11-16': 'waxing-gibbous',
  '2021-11-17': 'waxing-gibbous',
@nadiavanleur
Copy link
Author

nadiavanleur commented Jul 12, 2022

I'm using moment.js, so I am now getting the correct phases like this. Note that I only want to know if the moon phase happens on a certain day. Technically these moonphases happen only a specific time of that day.

const day = moment();
const lunarAgeStart = Moon.lunarAgePercent(day.startOf(`day`).toDate());
const lunarAgeEnd = Moon.lunarAgePercent(day.endOf(`day`).toDate());


if (lunarAgeStart <= 1 && lunarAgeStart >= 0.9 && lunarAgeEnd >= 0 && lunarAgeEnd <= 0.1) {
      return `new`;

} else if (lunarAgeStart <= 0.25 && lunarAgeEnd >= 0.25) {
      return `first-quarter`;

} else if (lunarAgeStart <= 0.5 && lunarAgeEnd >= 0.5) {
      return `full`;

} else if (lunarAgeStart <= 0.75 && lunarAgeEnd >= 0.75) {
      return `last-quarter`;
}

@jasonsturges
Copy link
Owner

@nadiavanleur Hi, each phase is 3.691 days in a ~29.5 day lunar month for 12 lunations a year. This intercalation normalizes years (and leap years) providing accuracy for the next 31,000 years at which point this calculation will be 1-day behind.

Yes, there are primary and intermediary phases.

The idea of an event is difficult to encapsulate here - it would be a fractional moment in time, essentially never shown.

Original intent of this package was weather station graphics implementation, giving a user indication of the current phase.

image

Still contemplating user feedback in terms of the next version of this package.

There's diversity in application that people want to leverage, and I believe configuration through an options pattern is possible. Working on that now, though distracted with other pressing responsibilities. Understanding how this is used in your application might help.

Also, note that Moment.js is deprecated, now in maintenance mode. You might want to consider a different package like day.js.

@jasonsturges
Copy link
Owner

Created #24 to isolate the primary concern here.

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

No branches or pull requests

2 participants