jasonsturges / lunarphase-js

Calculate phase of the moon using Julian date
https://jasonsturges.github.io/lunarphase-js/
ISC License
85 stars 13 forks source link

Lunar Day Calculation #18

Open ryanve opened 3 years ago

ryanve commented 3 years ago

Cool library. How about adding a lunarDay method to calculate the lunar day. Seems doable by dividing the lunar age. On the new moon it'd return 1 and so on. Returning a float would work or have lunarDay return a floored integer and accompany it with a lunarDayPercent method that returns how far into that day we are. Thoughts?

jasonsturges commented 3 years ago

@ryanve Hi, thanks.

The lunageAge() should do that - it's Earth days since the last new moon.

Lunar Age

Age in Earth days through the current lunar cycle, equivalent to 29.53059 Earth days, based on Mean Synodic Month, 2000 AD mean solar days.

Phase Start Event End
New 0 1.84566173161
Waxing Crescent 1.84566173161 3.69132346322 5.53698519483
First Quarter 5.53698519483 7.38264692644 9.22830865805
Waxing Gibbous 9.22830865805 11.07397038966 12.91963212127
Full 12.91963212127 14.76529385288 16.61095558449
Waning Gibbous 16.61095558449 18.4566173161 20.30227904771
Last Quarter 20.30227904771 22.14794077932 23.99360251093
Waning Crescent 23.99360251093 25.83926424254 27.68492597415
New 27.68492597415 29.53058770576

To get the lunar age (ex: 16.54412413414952)

const age = Moon.lunarAge();

Does that work for you?

ryanve commented 2 years ago

@jasonsturges thank you i've been wondering whether lunar days are different and i think lunar days are different than earth days. For example just before the new moon tomorrow will be the 30th lunar day. Lunar days are used in astrology like in this business calendar or shopping calender or haircut calender

jasonsturges commented 2 years ago

@ryanve Interesting, I'm not familiar how astrology calculates this.

Lunar vs lunisolar calendars align lunar months with the solar year through different intercalation - approximately 29.5 days, although it appears some calendars alternate between 29 and 30 day synodic months to complete one year of 12 lunations.

Here, using the Gregorian calendar, this fraction normalizes years (and leap years) providing accuracy for the next 31,000 years at which point this calculation will be 1-day behind.

But it is interesting that over this ~25,000 day fraction are 451 30-day full months and 399 29-day hollow months.

Not sure where to go from here... I'll look at how these alternating full / hollow months fit into current calculations, but there are other variations that might be applicable to your needs of astrology.

Would you know roots of astrology lunar calendars? Would they stem from Chinese, Hebrew, Hindu, Islamic, or other culture?

ryanve commented 2 years ago

An Indian women explains about it YouTube. Sounds calculable in a global way but she says timezone has influence in application with local sunrise. MoonHoroscope has it on their homepage.

dannylin108 commented 1 year ago

I will be surprised, but Chinese astrology / Chinese calendar is doing it in another different way. Some months have 29 lunar days, others have 30. This way they approximate average 29.53059 days synodic month.

jasonsturges commented 1 year ago

@dannylin108 Yes, this average calculation provides accuracy for the next 31,000 years.

Several people have asked for variations of these calculations for different purposes. Besides researching the calculations, I've implemented a new options system that should better facilitate these requests.