Re: Calendar and Days of the week
- From: Arturo Magidin <magidin@xxxxxxxxxxxxxx>
- Date: Thu, 19 Nov 2009 12:32:17 -0800 (PST)
On Nov 19, 11:17 am, jbriggs444 <jbriggs...@xxxxxxxxx> wrote:
On Nov 19, 10:38 am, "Greg Neill" <gneil...@xxxxxxxxxxxxxxxx> wrote:
Dave Seaman wrote:
I implemented your algorithm in C as shown at the end of this post.
Using this definition, I was able to reproduce your counts for the
period 1800 <= year <= 5800. However, your algorithm seems to be
wrong for pretty much all dates beginning in the year 2101. For
example, your algorithm says January 1, 2101, is a Sunday. Actually,
it's a Saturday.
Yep. There seems to be a bug in theJulian Day calculation
I used that crops up at the year 2101. Thanks for pointing
this out; I'll need to take another look at it.
I was attempting to come up with a compact single line
function for Julian Day that didn't require auxilliary
temporary variables. Back to the drawing board...
Classic issue would be to ignore the 100 and 400 year leap rules, thus
getting an answer that's correct for March 1, 1900 through February
28, 2100. It's a tempting approximation/simplificatino.
Looking at your formula, I see the part that involves year has a
factor of exactly 365.25 on it. [367 - 7/4] So the century rules are
indeed missing and you probably have calendar creep of 3 days for
every 400 years.
But that is the point of doing the Julian day first, isn't it? In the
Julian calendar, the year is exactly 365.25 days in it, with a leap
year every four years, no century rules. As I understood it, the point
was to figure out the day it would be in the Julian calendar, and then
adjust the day to the Gregorian one by taking into account the Julian
calendar. Figuring out the Julian day is easy because you only have to
add one day per year, plus one day for every four years. Then you
take your Julian answer and adjust to the Gregorian one by taking into
account the century rules. The formula you mention was for the Julian
day.
For example, once Dave Seaman said the Gregorian cycle is 400 years
long (the Julian cycle is only 28 years long), here is how I mentally
checked that it: 400 days for the years, plus 100 for the leap years
is 500; this is 3 mod 7, so the Julian day has crept forward 3 days.
Take away the three extra leap years to get 0 mod 7 for the Gregorian
day, so we've cycled in days of the week and in sequence of leap-and-
non-leap years.
--
Arturo Magidin
.
- Follow-Ups:
- Re: Calendar and Days of the week
- From: Dave Seaman
- Re: Calendar and Days of the week
- References:
- Calendar and Days of the week
- From: Yves
- Re: Calendar and Days of the week
- From: Greg Neill
- Re: Calendar and Days of the week
- From: Dave Seaman
- Re: Calendar and Days of the week
- From: Greg Neill
- Re: Calendar and Days of the week
- From: jbriggs444
- Calendar and Days of the week
- Prev by Date: Re: Symmetric functions, Galois groups, and intermediate fields
- Next by Date: Re: Calendar and Days of the week
- Previous by thread: Re: Calendar and Days of the week
- Next by thread: Re: Calendar and Days of the week
- Index(es):
Relevant Pages
|