Live data from Hacker News

Show HN: Tiny Moon – Swift library to calculate the moon phase

github.com

21–30 of 41 posts

Re: Show HN: Tiny Moon – Swift library to calculate the moon phase

#21
I know a lot of people into fishing that would love this as an app to quickly check the moon phase on a given date when planning a multi-day fishing trip or deciding when to go out. Apex predators are typically less hungry around and during a full moon due to the extra light making hunting at night easy.

Re: Show HN: Tiny Moon – Swift library to calculate the moon phase

#22
And then, there was an anecdote!

I bought my friends daughter a watch for her birthday. She was, like, 12 or something. I got it at Target.

And it had a moon phase dial! How about that?!

So I was determined to set it accurately for her.

To wit I started dredging through the internet. And to be completely honest, I'm not quite sure how I was doing that, having nothing but a Netcom.com shell account available to me. Perhaps I was using Lynx, or using some mail gateway, or who knows what. It wasn't no 10 seconds on Google, I'll tell you that.

In the end, I stumbled upon some code for my HP-48. Aha! This should do nicely!

Somehow, I got the code into the calculator. Did I type it in? Did I download it over Kermit? Who knows. Times were moving fast back then. Somehow, someway, however, I got that code in and calculated away.

Finally! ACCURATE results. Done with precision and math and engineering. Done Right!

To wit, I then proceeded to get the watch set properly.

And...it was a fashion watch for a 12 year old girl from Target. This may come as a shock to some, I was obviously taken aback by it, however -- the moon phase did not work. It was just a moon on a dial that moved, though some undetermined mechanism. It could not be set independently.

Oh.

Re: Show HN: Tiny Moon – Swift library to calculate the moon phase

#24

And then, there was an anecdote! I bought my friends daughter a watch for her birthday. She was, like, 12 or something. I got it at Target. And it had a moon phase dial! How about that?! So I was determined to set it accurately for her. To wit I started dredging through the internet. And to be completely honest, I'm not quite sure how I was doing that, having nothing but a Netcom.com shell account available to me. Pe…

[deleted]

Re: Show HN: Tiny Moon – Swift library to calculate the moon phase

#25
If granular accuracy is not an important factor, you can also use Islamic calendar to calculate the moon phase. Muslims uses lunar cycles for some religious events (e.g. the Ayyamul Bidh or 3 days fasting during full moon). So when its 15 of an Islamic calendar, it’ll be a full moon.

I used this approach because most platforms supports islamic calendar.

I really like the offline first approach, and would definitely use the library when there’s a need.

Thanks for sharing!

Re: Show HN: Tiny Moon – Swift library to calculate the moon phase

#27
this looks incredibly bad from the implementation. there is a much simpler algorithm that works for hundreds of years in either direction of the present...

by comparison this is an absolute mountain of code. here is a good one - but note that it is only so accurate for each quarter phase (...and not sure why it destroys the formatting):

function approximateMoonPhase(julianDay)

{

    // from Meeus p.319

    // JDE = 2451 550.09765 + 29.530 588 853 k

    // + 0.000 1337 T2

    // - 0.000 000 150 T3

    // + 0.000 000 000 73 T4

    const t = toJulianCenturiesSinceJ2000(julianDay);

    const lhs = julianDay - 2451550.09765 + (-0.0001337 + (0.00000015 - 0.00000000073 * t) * t) * t * t;

    return lhs / 29.530588853;
}

enjoy. its from the same source as your work appears to use...

which, as someone who as implemented a ton of this stuff. its kind of a damning sentiment that we still refer to such an old book instead of learning the problem space and making better solutions... i have a whole book in me about this at some point.

Re: Show HN: Tiny Moon – Swift library to calculate the moon phase

#28

If granular accuracy is not an important factor, you can also use Islamic calendar to calculate the moon phase. Muslims uses lunar cycles for some religious events (e.g. the Ayyamul Bidh or 3 days fasting during full moon). So when its 15 of an Islamic calendar, it’ll be a full moon. I used this approach because most platforms supports islamic calendar. I really like the offline first approach, and would definitely u…

I wonder, how is Allah's tolerance towards technotheological errors?

What if there's a bug in the calendar for Ramadan or Salah?

Re: Show HN: Tiny Moon – Swift library to calculate the moon phase

#29

I know a lot of people into fishing that would love this as an app to quickly check the moon phase on a given date when planning a multi-day fishing trip or deciding when to go out. Apex predators are typically less hungry around and during a full moon due to the extra light making hunting at night easy.

the ios weather app has moon info for the current, previous, and next month

Re: Show HN: Tiny Moon – Swift library to calculate the moon phase

#30
post #27

this looks incredibly bad from the implementation. there is a much simpler algorithm that works for hundreds of years in either direction of the present... by comparison this is an absolute mountain of code. here is a good one - but note that it is only so accurate for each quarter phase (...and not sure why it destroys the formatting): function approximateMoonPhase(julianDay) { // from Meeus p.319 // JDE = 2451 550.…

> but note that it is only so accurate for each quarter phase

So it's not actually comparable at all?

Post reply on HN