Re: Calendar and Days of the week



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


.



Relevant Pages

  • Re: Julian date function
    ... according to the algorithm of the Julian calendar ... ... Yes, you are of course correct, the Julian calender uses %4 for leap years, ... whereas the Gregorian uses some extra conditions ... // Routines for processing dates in the format JDN. ...
    (microsoft.public.vc.language)
  • Re: It it now a leap year?
    ... even showing that the rules defined for leap ... Julian or Gregorian? ... Didn't Pope Gregory fixed the calendar, ...
    (Fedora)
  • Re: Calendar and Days of the week
    ... Julian calendar, the year is exactly 365.25 days in it, with a leap ... adjust the day to the Gregorian one by taking into account the Julian ... The Julian Day is how astronomers ...
    (sci.math)
  • Re: Why the US wants to end link between time and sun
    ... >>Making a leap hour won't solver the problems for programmers either. ... over the world, and I'm not just talking about Delphi either, the same date ... > One should never refer to Julian dates without explanation (the Julian ...
    (uk.sci.astronomy)
  • Re: Help in CalenderAPI
    ... for more information about julian date ... and trust on jdk only....and as mention on jdk doc the ... To obtain a pure Julian calendar, ... To obtain a pure Gregorian calendar, ...
    (comp.lang.java.programmer)