[Chugalug] Calculating the next Thanksgivukkah

Chad Smith chad78 at gmail.com
Wed Oct 9 05:55:12 UTC 2013


79043?

That's crazy.  It's also a prime number.  So, that's weird.

*- Chad W. Smith*


On Tue, Oct 8, 2013 at 10:37 PM, Robert A. Kelly III <
bluethegrappler at gmail.com> wrote:

> On 10/08/2013 09:39 PM, Robert A. Kelly III wrote:
> > I found the problem in the HebToJul() function in hbcal.c:
> >
> > int HebToJul(int hy, int hm, int hd)
> > {
> >     int ylen;
> >     char const *monlens;
> >     int rh;
> >     int m;
> >
> >     /* Do some range checking */
> >     if (hy - 3761 < BASE || hy - 3760 > BASE+YR_RANGE) return -1;
> >
> >     ylen = DaysInHebYear(hy);
> >     monlens = DaysInHebMonths(ylen);
> >
> >     /* Get the Rosh Hashana of the year */
> >     rh = RoshHashana(hy);
> >
> >     /* Bump up to the appropriate month */
> >     for (m=0; m<hm; m++) rh += monlens[m];
> >
> >     /* Add in appropriate number of days */
> >     rh += hd - 1;
> >     return rh;
> > }
> >
> > When this function returns <0, GetNextHebrewDate() returns E_DATE_OVER.
> > Quick and dirty fix, commenting out the range checking line allowed me
> > to determine that the next date of Thanksgivukkah is indeed November 23,
> > 79043!
>
> A further examination shows that YR_RANGE is based on the assumption of
> a 32-bit signed integer:
>
> /*---------------------------------------------------------------------*/
> /* YR_RANGE: The range of years allowed.  With 32-bit signed integers, */
> /* the DATETIME type can store 2^31 minutes or about 4074 years.       */
> /*---------------------------------------------------------------------*/
> #define YR_RANGE 4000
>
> With a 64-bit signed integer, it should be safe to use:
>
> #define YR_RANGE 17536635926176
>
> Incidentally, I also noticed that the location for calculating things
> like sunrise and sunset is hardcoded with the assumption of Ottawa,
> Ontario, Canada. I guess remind really was intended to be compiled by
> the user, LOL. It truly is, there is actually a GUI that lets you set
> your latitude and longitude when you compile it. YR_RANGE, however, is
> not intended to be altered so easily. The compile script should probably
> automatically check for a 64-bit architecture and adjust accordingly.
> _______________________________________________
> Chugalug mailing list
> Chugalug at chugalug.org
> http://chugalug.org/cgi-bin/mailman/listinfo/chugalug
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://chugalug.org/pipermail/chugalug/attachments/20131009/2dc2236b/attachment.html>


More information about the Chugalug mailing list