Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Curiously, when I compile and run the nethack example I get "2" as the answer ("First Quarter" which is the same as your port)</p> <pre><code>#include &lt;time.h&gt; static struct tm * getlt() { time_t date; (void) time(&amp;date); return(localtime(&amp;date)); } /* * moon period = 29.53058 days ~= 30, year = 365.2422 days * days moon phase advances on first day of year compared to preceding year * = 365.2422 - 12*29.53058 ~= 11 * years in Metonic cycle (time until same phases fall on the same days of * the month) = 18.6 ~= 19 * moon phase on first day of year (epact) ~= (11*(year%19) + 29) % 30 * (29 as initial condition) * current phase in days = first day phase + days elapsed in year * 6 moons ~= 177 days * 177 ~= 8 reported phases * 22 * + 11/22 for rounding */ int phase_of_the_moon() /* 0-7, with 0: new, 4: full */ { register struct tm *lt = getlt(); register int epact, diy, goldn; diy = lt-&gt;tm_yday; goldn = (lt-&gt;tm_year % 19) + 1; epact = (11 * goldn + 18) % 30; if ((epact == 25 &amp;&amp; goldn &gt; 11) || epact == 24) epact++; return( (((((diy + epact) * 6) + 11) % 177) / 22) &amp; 7 ); } int main(int argc, char * argv[]) { printf ("phase of the moon %d\n\n", phase_of_the_moon()); } </code></pre> <p>output:</p> <pre><code>&gt; a.out phase of the moon 2 </code></pre> <p>But that doesn't seem like the right answer, as today, weatherunderground.com and alt.org reports the phase of the moon as "Waxing Gibbous" (a.k.a 3).</p> <p>I tried remove the "-1900" but that didn't result in the right answer either.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload