[comp.lang.pascal] leap year function

bakerre@tawc1.eglin.af.mil (Baker, Robert E.) (05/16/91)

	I'm looking for source for a function that determines whether or not a
year is a leap year.  Anybody got it.  ADVthanksANCE.

+----------------------------------+------------------------------------------+
| Robert E. Baker                  |                                          |
| BAKERRE@TAWC1.EGLIN.AF.MIL       |    This space intentionally left blank   |
| USAF Tactical Air Warfare Center |                                          |
| "Bob's opinions are BOB's!"      |                                          |
+----------------------------------+------------------------------------------+

dvlhma@cs.umu.se (Henrik Magnusson) (05/17/91)

In article <26912@adm.brl.mil> bakerre@tawc1.eglin.af.mil (Baker, Robert E.) writes:
>
>	I'm looking for source for a function that determines whether or not a
>year is a leap year.  Anybody got it.  ADVthanksANCE.
>

To determine if a year is a leap year or not is pretty easy.
If the year is not a hundred (1988, 1989, 1990) then the year should be
divisable with 4 to be a leapyear. If the year is a hundred (1800, 1900,
2000) then the year should be divisable with 400.

Here is a quickly written function.

FUNCTION is_leap_yeat(year :integer) :Boolean;
BEGIN
  is_leap_year := ((year MOD 4) AND NOT (year mod 100)) OR (year MOD 400);
END;

/NeNNe


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Henrik Magnusson           :: "How'd you puncture that tyre?"           ::
:: dvlhma@cs.umu.se           :: "Ran over a milk bottle"                  ::
::                            :: "Didn't you see it?"                      ::
:: Umeaa University, Sweden   :: "Damn kid had it under his coat."         ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

DAVID@ches.cs.vims.edu (05/17/91)

This should work as a leap year function:

function leap(year : integer) : boolean;
begin
  if year mod 100 = 0 then
    leap := year mod 400 = 0
  else
    leap := year mod 4 = 0
end;

This won't work historically, of course, for political and religious
reasons.  The omission of century years not divisible by 400 was only
introduced with the Gregorian calendar in the 1500's. Thus 1700 was
not a leap year -- in Roman Catholic countries, but in England and the
American colonies, 1700 was a leap year. Russia only adopted the Gregorian
calendar this century so they did not miss in 1800 and 1900 either!

David Evans
david@ches.cs.vims.edu

neile@hls.com (05/17/91)

In article <26912@adm.brl.mil>, bakerre@tawc1.eglin.af.mil (Baker, Robert E.) writes:
> 
> 	I'm looking for source for a function that determines whether or not a
> year is a leap year.  Anybody got it.  ADVthanksANCE.
> 
The test for a leap year is simple; year mod 4 = 0.  There is no reason to
add complexity as indicated in other postings.

Neil Everhart 

dslg0849@uxa.cso.uiuc.edu (Daniel S. Lewart) (05/18/91)

neile@hls.com writes:

> The test for a leap year is simple; year mod 4 = 0.  There is no reason to
> add complexity as indicated in other postings.

Unless, of course, you want to do it correctly.

Daniel Lewart
d-lewart@uiuc.edu

reeses@milton.u.washington.edu (Feltch Master) (05/18/91)

In article <1991May17.074806.130@hls.com> neile@hls.com writes:
>In article <26912@adm.brl.mil>, bakerre@tawc1.eglin.af.mil (Baker, Robert E.) writes:
>> 
>> 	I'm looking for source for a function that determines whether or not a
>> year is a leap year.  Anybody got it.  ADVthanksANCE.
>> 
>The test for a leap year is simple; year mod 4 = 0.  There is no reason to
>add complexity as indicated in other postings.
>
>Neil Everhart 

Yes, there is a need for complexity...years divisible by 100 that are not also
divisible by 400 are not leap years.  1900 was not a leap year, despite the
fact that it was divisible by 4.  2000 will be, as will 2400, as will 2800,
etc.

Art Taylor

-- 
-------------------------------------------------------------------------------
reeses@milton.u.washington.edu   University of Washington, Seattle
"Reality is a cop-out for people who can't handle drugs"

Jonathan.Bradshaw@thevoid.fidonet.org (Jonathan Bradshaw) (05/18/91)

In a message of <May 17 15:48>, UUCP (neile@hls.com
 
 U>The test for a leap year is simple; year mod 4 = 0.  There is no reason to
 U>add complexity as indicated in other postings.

Buzzz.. wrong, all centuries that are divisible by 4 are NOT leap years, only 
if they are divisible by 400...
  


 * Origin: VOIDian Gateway of Michiana (thevoid.fidonet.org) (1:227/1.6)

ins845b@monu4.cc.monash.edu.au (mr k.l. lentin) (05/18/91)

In article <1991May17.074806.130@hls.com> neile@hls.com writes:
>In article <26912@adm.brl.mil>, bakerre@tawc1.eglin.af.mil (Baker, Robert E.) writes:
>> 
>> 	I'm looking for source for a function that determines whether or not a
>> year is a leap year.  Anybody got it.  ADVthanksANCE.
>> 
>The test for a leap year is simple; year mod 4 = 0.  There is no reason to
>add complexity as indicated in other postings.
>
>Neil Everhart 

Not altogether true. All century years that are not multiples of 400 are NOT
leap years so 1600 IS a leap year 1700,1800,1900 WERE and 2000 will be!
If thats not a problem year mod 4 = 0 works fine.

|/
|\evin

dvlhma@cs.umu.se (Henrik Magnusson) (05/18/91)

In article <1991May17.074806.130@hls.com> neile@hls.com writes:
>In article <26912@adm.brl.mil>, bakerre@tawc1.eglin.af.mil (Baker, Robert E.) writes:
>> 
>> 	I'm looking for source for a function that determines whether or not a
>> year is a leap year.  Anybody got it.  ADVthanksANCE.
>> 
>The test for a leap year is simple; year mod 4 = 0.  There is no reason to
>add complexity as indicated in other postings.
>
>Neil Everhart 
Sorry but it year MOD 4= 0 isn't enough. 1900 isn't a leapyear, but 2000 is!
/NeNNe

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Henrik Magnusson           :: "How'd you puncture that tyre?"           ::
:: dvlhma@cs.umu.se           :: "Ran over a milk bottle"                  ::
::                            :: "Didn't you see it?"                      ::
:: Umeaa University, Sweden   :: "Damn kid had it under his coat."         ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

kai@kaiki.toppoint.de (Kai Voelcker) (05/18/91)

neile@hls.com writes:
> The test for a leap year is simple; year mod 4 = 0.  There is no reason to
> add complexity as indicated in other postings.
> Neil Everhart 

And what's about 1900? That's   n o t   a leap year!
 ________________________________________________________________________
 | Kai Voelcker, Kappelner Str 18, D-2300 Kiel 1, voice: +49 431 335605 |
 | kai@kaiki.toppoint.de    interests: 386asm, c, pascal; OR algorithms |
 |   >>>  polite notice: I have to pay for incoming mail. Thanks  <<<   |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

hoffmann@infopls.chi.il.us (Robert Hoffmann) (05/19/91)

neile@hls.com writes:

> > 	I'm looking for source for a function that determines whether or not a
> > year is a leap year.  Anybody got it.  ADVthanksANCE.
   
> The test for a leap year is simple; year mod 4 = 0.  There is no reason to
> add complexity as indicated in other postings.
 
Sure there is.  Several hundred years ago, the rules for century years 
(ones ending in 00) were changed... deleting 3 leap years every 400 years 
helps keep the calendar intact and the seasons happening on the right 
dates...
 
If (year mod 100) = 0, then if (year mod 400) <> 0, it's not a leap year.
 
That's why the complexity... 

Kai_Henningsen@ms.maus.de (Kai Henningsen) (05/21/91)

neile @ hls.com schrieb am Fr 17.05.1991, 13:48 A16170@SUB in Cl-Pascal:

ne>The test for a leap year is simple; year mod 4 = 0.  There is no reason to
ne>add complexity as indicated in other postings.

This, of course, assumes that you will never be interested in years before 1901
or after 2099. I would prefer not to make such an assumption. Then, the (still
simple) rule is of course

    (year mod 4 = 0) and ((year mod 100 <> 0) or (year mod 400 = 0))

That's for the Gregorian calender. Once you leave *that* ground, it gets
complicated.
--
Kai Henningsen  Internet: kh@ms.maus.de
Muenster         UUCP: any_backbone_that_knows_domains!ms.maus.de!kh
Germany         Fido: kh%maus ms, 2:242/2.6 or Kai Henningsen, 2:242/2.244

g_harrison@vger.nsu.edu (George C. Harrison, Norfolk State University) (05/21/91)

In article <1991May18.112519.3371@monu0.cc.monash.edu.au>, ins845b@monu4.cc.monash.edu.au (mr  k.l. lentin) writes:
> In article <1991May17.074806.130@hls.com> neile@hls.com writes:
>>In article <26912@adm.brl.mil>, bakerre@tawc1.eglin.af.mil (Baker, Robert E.) writes:
>>> 
>>> 	I'm looking for source for a function that determines whether or not a
>>> year is a leap year.  Anybody got it.  ADVthanksANCE.
>>> 
>>The test for a leap year is simple; year mod 4 = 0.  There is no reason to
>>add complexity as indicated in other postings.
>>
>>Neil Everhart 
> 
> Not altogether true. All century years that are not multiples of 400 are NOT
> leap years so 1600 IS a leap year 1700,1800,1900 WERE and 2000 will be!
> If thats not a problem year mod 4 = 0 works fine.
> 
> |/
> |\evin

It really depends on the application.  

As a mathematician I'd like to see the total rule in effect, but consider 
this.....   

If the program was to run for the next 108 or so years continually, could the
programmer be fired???  (assuming, of course, that the program was to determine
the current day, etc. and not some day of the week that occured in history
{before 1901})

I have a function which is really neat, but I am sure 1578 people have emailed
it to him already.  There are probably those who will post all date alterations
(Julian calendar, etc.) since Adam and Eve and even since God first saw "that
it was good."



George....

-- George C. Harrison                              -----------------------
----- Professor of Computer Science                -----------------------
----- Norfolk State University                     -----------------------
----- 2401 Corprew Avenue, Norfolk, Virginia 23504 -----------------------
----- INTERNET:  g_harrison@vger.nsu.edu ---------------------------------

CDHWilli@exua.exeter.ac.uk (Charles Williams) (05/21/91)

>The test for a leap year is simple; year mod 4 = 0.  There is no reason to
>add complexity as indicated in other postings.
>
>Neil Everhart 

Isn't there something odd about the centuries and millenia?

d89mb@efd.lth.se (Magnus Bodin) (05/22/91)

>>The test for a leap year is simple; year mod 4 = 0.  There is no reason to
>>add complexity as indicated in other postings.
>>
>>Neil Everhart

>Isn't there something odd about the centuries and millenia?

Yes, sort of. 

Leap year occurs every year that is even dividable by 4, eg 1984,
1988, 1992...

But, it does NOT occur when the year is even dividable by 100, eg.
1800, 1900

UNLESS it's not even dividable by 400  AS WELL... Therefore 2000 is a
leap year.


If you just divide by 4, you won't have wrong until 2100.


Takelr|,

Magnus
-- 
Magnus Bodin               "Nec fasces, nec opes, 
Institute of Tychology,     sola artis sceptra perennant"
Box 5127, 220 05 Sweden     (Tycho Brahe, Stj{rneborg 1584)

acm@Sun.COM (Andrew MacRae) (05/23/91)

In article <15921@ms.maus.de>, Kai_Henningsen@ms.maus.de (Kai Henningsen) writes:
> This, of course, assumes that you will never be interested in years before 1901
> or after 2099. I would prefer not to make such an assumption. Then, the (still
> simple) rule is of course

It's funny, but in close to fifteen years of programming I have yet to discover
a need to handle dates before 1901 or after 2099.  Of course I have only
developed real-time systems, operating systems, compilers, linkers, and far
too many data base applications.

Other than a super duper calendar program or a star charting program, I am
at a loss to think of a reason to go past those dates in either direction, at
least for the purpose of finding the day of the week.

In the forward direction, it is rather silly to believe that your pc (or your
software) will still be in use in the year 2100.  (Yes, yes, I know, maybe
the person posting is building a machine that *is* supposed to last that
long.  Frankly I doubt it.)

In the backward direction, the problem with the rule mentioned in the previous
posting is that it only takes you back to the year 1722 (I think).  That was the
year that eleven days were dropped from the calendar.  Unless you account for
that you are still off.  (I may be off on the exact year.)  The only program
that I am familier with that *does* handle those missing eleven days is a
calendar program running (I think) under UNIX.

Does anyone have an example (other than the two I mentioned above) where their
program had to know the day of the week for a date before 1901 or after 2099?

						Andrew MacRae
						

marcos@allanon.UUCP (Marcos Della) (05/23/91)

kai@kaiki.toppoint.de (Kai Voelcker) writes:

> neile@hls.com writes:
> > The test for a leap year is simple; year mod 4 = 0.  There is no reason to
> > add complexity as indicated in other postings.
> > Neil Everhart 
> 
> And what's about 1900? That's   n o t   a leap year!

how about changing it to the following:

   leap_year := (year MOD 4 = 0) AND
                ((year MOD 100 <> 0) OR (year MOD 400 = 0));

That should clear up the hundred and four hundred year problem...

Marcos


____________________________________________________________________________
Marcos R. Della                           | Did you ever wonder if there was
allanon!marcos@petunia.CalPoly.EDU (home) | more to the universe than this?
mdella@polyslo.CalPoly.EDU       (school) |
marcos.della@f185.n125.z1.fidonet.org     |         ...I didn't...

Robert_Salesas@mindlink.bc.ca (Robert Salesas) (05/23/91)

Yeah, I could just imagine the new watches coming out just for that particular
day, I suppose that with digital watches there wouldn't be any problem...

Rob
--
\--------------------------------------------------------------------/
\ Robert Salesas             + Usenet: Robert_Salesas@MINDLINK.bc.ca /
\ Eschalon Development Inc.  + CIS:    76625,1320    BYTE:  newdawn  /
\--------------------------------------------------------------------/

defaria@hpcupt3.cup.hp.com (Andy DeFaria) (05/24/91)

I got an idea.  The reason we  even have a  leap  year at  all is because a
year is slightly more than 365 days.  It's something like  365 days 5 hours
48 minutes and 46 seconds.  Why not simply do away with leap day altogether
and insert the 1/4 day after 12/31 of the year.   Make is a variable length
day to accomidate the changes in the earths rotation around the  sun.  Hell
I'm sure that most people would enjoy the  extra 1/4  for rest after a good
New Years Party! :-)

acm@Sun.COM (Andrew MacRae) (05/24/91)

In article <JPRD34w164w@allanon.UUCP>, marcos@allanon.UUCP (Marcos Della) writes:
> how about changing it to the following:
> 
>    leap_year := (year MOD 4 = 0) AND
>                 ((year MOD 100 <> 0) OR (year MOD 400 = 0));
> 
> That should clear up the hundred and four hundred year problem...

But it *doesn't* clear up the 1722 problem.  (In 1722, eleven days were
dropped out of the month of September.)

I guess you could call 1722 a super duper negative leap year, that is in
regular leap years one day is added.  In a sdn leap year eleven days
are dropped.

It's a pity that they didn't drop them from February.

						Andrew MacRae

etxbjk@solsta.ericsson.se (Bjorn Karlsen TX/DKI) (05/24/91)

>In the backward direction, the problem with the rule mentioned in the previous
>posting is that it only takes you back to the year 1722 (I think).  That was
>year that eleven days were dropped from the calendar.  Unless you account for
>that you are still off.  (I may be off on the exact year.)  The only program
>that I am familier with that *does* handle those missing eleven days is a
>calendar program running (I think) under UNIX.

The year was 1752. Here's the output from UNIX' cal:

				1752

	 Jan			Feb		       Mar
 S  M Tu  W Th  F  S    S  M Tu  W Th  F  S    S  M Tu  W Th  F  S
          1  2  3  4                      1    1  2  3  4  5  6  7
 5  6  7  8  9 10 11    2  3  4  5  6  7  8    8  9 10 11 12 13 14
12 13 14 15 16 17 18    9 10 11 12 13 14 15   15 16 17 18 19 20 21
19 20 21 22 23 24 25   16 17 18 19 20 21 22   22 23 24 25 26 27 28
26 27 28 29 30 31      23 24 25 26 27 28 29   29 30 31

	 Apr			May		       Jun
 S  M Tu  W Th  F  S    S  M Tu  W Th  F  S    S  M Tu  W Th  F  S
          1  2  3  4                   1  2       1  2  3  4  5  6
 5  6  7  8  9 10 11    3  4  5  6  7  8  9    7  8  9 10 11 12 13
12 13 14 15 16 17 18   10 11 12 13 14 15 16   14 15 16 17 18 19 20
19 20 21 22 23 24 25   17 18 19 20 21 22 23   21 22 23 24 25 26 27
26 27 28 29 30         24 25 26 27 28 29 30   28 29 30
                       31
	 Jul			Aug		       Sep
 S  M Tu  W Th  F  S    S  M Tu  W Th  F  S    S  M Tu  W Th  F  S
          1  2  3  4                      1          1  2 14 15 16
 5  6  7  8  9 10 11    2  3  4  5  6  7  8   17 18 19 20 21 22 23
12 13 14 15 16 17 18    9 10 11 12 13 14 15   24 25 26 27 28 29 30
19 20 21 22 23 24 25   16 17 18 19 20 21 22
26 27 28 29 30 31      23 24 25 26 27 28 29
                       30 31
	 Oct			Nov		       Dec
 S  M Tu  W Th  F  S    S  M Tu  W Th  F  S    S  M Tu  W Th  F  S
 1  2  3  4  5  6  7             1  2  3  4                   1  2
 8  9 10 11 12 13 14    5  6  7  8  9 10 11    3  4  5  6  7  8  9
15 16 17 18 19 20 21   12 13 14 15 16 17 18   10 11 12 13 14 15 16
22 23 24 25 26 27 28   19 20 21 22 23 24 25   17 18 19 20 21 22 23
29 30 31               26 27 28 29 30         24 25 26 27 28 29 30
                                              31



--
=========================================================================
Bj|rn Karlsen                                etxbjk@solsta.ericsson.se   
Ericsson Telecom                            etx.etxbjk@memo.ericsson.se
S-652 21 Karlstad, SWEDEN                     etxbjk@lmej.ericsson.se    
=========================================================================
"Det einaste eg var stiv i p} skulen, var nakken" - Trond Kirkvaag

jja@wsl.ie (John Allen on wsl) (05/24/91)

In article <4165@jethro.Corp.Sun.COM> acm@Sun.COM (Andrew MacRae) writes:
>It's funny, but in close to fifteen years of programming I have yet to discover
>a need to handle dates before 1901 or after 2099.  Of course I have only

How about a hospital records system, you know some people that were born
before 1901 are still alive today. As I keep saying there is no reason
to do anything incorrectly when it's just as easy to do it right.


-----------------------------------------------------------------------------
		|\/\/\/|
		|      |
		| (-)(o)
		|     _)
		| ,___|    
		|   /   
	   /____\   And the BART raised up his hands and said unto the masses.

People that don't know want to know from the people that do know and if the 
poeple that do know don't tell the people that don't know then the people
that don't know still won't know.
   "Don't quote me on any issue whatsoever, unless you feel oblidged to."

R.Smithers@ee.surrey.ac.uk (Russell Smithers) (05/24/91)

neile@hls.com writes:
> The test for a leap year is simple; year mod 4 = 0.  There is no reason to
> add complexity as indicated in other postings.
> Neil Everhart 

And what's about 1900? That's   n o t   a leap year!
 ________________________________________________________________________
 | Kai Voelcker, Kappelner Str 18, D-2300 Kiel 1, voice: +49 431 335605 |
 | kai@kaiki.toppoint.de    interests: 386asm, c, pascal; OR algorithms |
 |   >>>  polite notice: I have to pay for incoming mail. Thanks  <<<   |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Actualy I saw something resantly about this exact problem i think it was c code but I noticed its not just mod 4 its a check with mod 100.
 Ill dont think I can find the artical any more but its not that much, its about 3 -4 lines of code max with an if else if I remember!

Any way im sure someone else will post the answer.

Conrad.Bullock@comp.vuw.ac.nz (Conrad Bullock) (05/25/91)

In article <1991May25.031535.1054@cs.mcgill.ca>, einstein@cs.mcgill.ca
(Michael CHOWET) writes:
|>   So, getting back to the original purpose of this post, the function
|> would
|> look more like: 
|> 
|>   function LEAPYEAR ( year : integer ) : boolean ;
|> 
|>     begin
|> 
|>       LEAPYEAR := ( year mod 100 <> 0 ) and ( year mod 4 = 0 ) ;
|> 
|>     end { of function LEAPYEAR } ;

I think that there is an additional rule - if a year is divisible by 400,
then it IS a leap year - so 2000 is divisible by 4, so it is a leap year, but
it is divisible by 100, so it ISN'T a leap year, but it is divisible by 400,
so it IS a leap year.

This rule is significant, with 2000 coming up. If you just forget about the
whole lot, and use being divisible by 4, then your program will work until
the year 2100.
-- 
Conrad Bullock                     | Domain:   conrad@comp.vuw.ac.nz
Victoria University of Wellington, |     or:   conrad@cavebbs.gen.nz
New Zealand.                       | Fidonet:  3:771/130
                                   | BBS:      The Cave BBS +64 4 643429

marcos@allanon.UUCP (Marcos Della) (06/03/91)

acm@Sun.COM (Andrew MacRae) writes:
>In article <JPRD34w164w@allanon.UUCP>, marcos@allanon.UUCP (Marcos Della)
>> how about changing it to the following:
>> ...
> 
> But it *doesn't* clear up the 1722 problem.  (In 1722, eleven days were
> dropped out of the month of September.)
> 

You know, I didn't know about the 1722 year.  What month did they drop out the
days from?  Or did they just shorten all the months except February.

Also, why the heck di they do it and why that particular year?

Marcos


____________________________________________________________________________
Marcos R. Della                           | Did you ever wonder if there was
allanon!marcos@petunia.CalPoly.EDU (home) | more to the universe than this?
mdella@polyslo.CalPoly.EDU       (school) |
marcos.della@f185.n125.z1.fidonet.org     |         ...I didn't...

baillie@mullauna.cs.mu.OZ.AU (Stephen Baillie) (06/05/91)

marcos@allanon.UUCP (Marcos Della) writes:

>acm@Sun.COM (Andrew MacRae) writes:
>>In article <JPRD34w164w@allanon.UUCP>, marcos@allanon.UUCP (Marcos Della)
>>> how about changing it to the following:
>>> ...
>> 
>> But it *doesn't* clear up the 1722 problem.  (In 1722, eleven days were
>> dropped out of the month of September.)
			       ^^^^^^^^^  -  Note this ?
>> 

>You know, I didn't know about the 1722 year.  What month did they drop out the
>days from?  Or did they just shorten all the months except February.

See the indicated section above? Good.

>Also, why the heck di they do it and why that particular year?

It was because of a discrepancy between the number of days in a year in the
old (Julian?) Calendar, ie one without leap years, and the actual passage
of the earth around the sun (did I get that the right way around? ;-> )

The year was out of sync with the sun by 11 days, so at the same time as
introducing leap years they cut a few days to make things line up again.
Caused quite a stir among the superstitious peasants who thought they
were losing a few days out of their lives!

I think that pre-1722 there were no leap years, so your program may try to
compensate for this too.

Steve.

"If we shadows have offended, Think but this and all is mended:
 That you have but slumbered here, While these visions did appear.
 And this weak and idle theme, no more yielding but a dream."
baillie@mullauna.cs.mu.oz.au (Stephen Baillie)

oep@gi.uio.no (Oeyvind Pedersen) (06/06/91)

In article <baillie.676098437@mullauna>, baillie@mullauna.cs.mu.OZ.AU
(Stephen Baillie) writes:
 
> It was because of a discrepancy between the number of days in a year
in the
> old (Julian?) Calendar, ie one without leap years, and the actual
passage
> of the earth around the sun (did I get that the right way around? ;->
)
> 
> The year was out of sync with the sun by 11 days, so at the same time
as
> introducing leap years they cut a few days to make things line up
again.
> Caused quite a stir among the superstitious peasants who thought they
> were losing a few days out of their lives!
> 
> I think that pre-1722 there were no leap years, so your program may
try to
> compensate for this too.

The Julian calendar HAD leap years.  The problem was that it had too
many - 25 in each century,
while the Gregorian calendar has 24.25, that is 24 in three centuries
and 25 in the fourth.
That makes an average year 365.2425 days long instead of 365.25, while
the "real" year, i.e
the time the earth uses in one lap is about 365.2422 days.

Oeyvind.

cssjs2@ufhx1 (Mr JM Scheepers) (06/06/91)

In <a4Dy31w164w@allanon.UUCP> marcos@allanon.UUCP (Marcos Della) writes:

>acm@Sun.COM (Andrew MacRae) writes:
>>In article <JPRD34w164w@allanon.UUCP>, marcos@allanon.UUCP (Marcos Della)
>> But it *doesn't* clear up the 1722 problem.  (In 1722, eleven days were
>> dropped out of the month of September.)
>> 

>You know, I didn't know about the 1722 year.  What month did they drop out the
>days from?  Or did they just shorten all the months except February.

>Also, why the heck di they do it and why that particular year?
>Marcos

The Julian calendar (after Caesar) was introduced in 45 BC, but because of
its simple rules for leap years, Pope Gregory  XIII introduced changes to
correct the discrepancy. He decreed that Thursday, October 4, 1582 would be
followed by Friday, October 15. The British Empire only accepted this in 
1752, and Russia only after the revolution, in 1918.

A function for calculating leap years would be:

function Leap(y: year): boolean;
begin
  Leap := (y mod 4 = 0) and ((y mod 100 <> 0) or (y mod 400)=0))
end

-- 
Inus Scheepers | Internet cssjs2@ufhx1.ufh.ac.za |Disclaimer: Is it my fault
Dept Comp Sci  | Phone +27 404 32011 x 2488 |     that power walks on
Univ Fort Hare | Fax   +27 404 31669 |            crooked legs? 
P/Bag X1314, Alice 5700, Ciskei, South Africa |

ts@uwasa.fi (Timo Salmi) (06/07/91)

In article <a4Dy31w164w@allanon.UUCP> marcos@allanon.UUCP (Marcos Della) writes:
:
>You know, I didn't know about the 1722 year.  What month did they drop out the
>days from?  Or did they just shorten all the months except February.
>
>Also, why the heck di they do it and why that particular year?
:

I seem to recall that the information can be found in Numerical
Recipes.

...................................................................
Prof. Timo Salmi
Moderating at garbo.uwasa.fi anonymous ftp archives 128.214.12.37
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun

Kai_Henningsen@ms.maus.de (Kai Henningsen) (06/08/91)

Stephen Baillie baillie%mullauna.cs.mu.OZ.AU @ SUB schrieb am Mi 05.06.1991,
03:07 A18353@SUB in Cl-Pascal:

SB>It was because of a discrepancy between the number of days in a year in the
SB>old (Julian?) Calendar, ie one without leap years, and the actual passage
SB>of the earth around the sun (did I get that the right way around? ;-> )

In fact, no .. see below.

SB>The year was out of sync with the sun by 11 days, so at the same time as
SB>introducing leap years they cut a few days to make things line up again.
SB>Caused quite a stir among the superstitious peasants who thought they
SB>were losing a few days out of their lives!

That, however, is ok ...

SB>I think that pre-1722 there were no leap years, so your program may try to
SB>compensate for this too.

It's like this: before the Gregorian calender, we had the Julian calender, so
named after one Julius Caesar, I believe, who in the year 46 BC reformed the
then-without-leap-years calender to include one every four years - this made a
calendar year of 365.25 days instead of 365. (That's why we have a month called
july: before, it was quintilis ...) As the actual year length is more like
365.2422, however, this still caused problems. In 1582 (not 1722) pope Gregor
the umpteenth decided enough was enough, dropped the 5.-14. october(!) and
invented some more leap days, bringing the year to 365.2425 days. The
difference of about 0.0003 days/year makes an error of one day in 3000 years -
we might as well forget that :-)

However, there is more. Not every nation accepted Gregor's decision at once.
Russia, for example, officially adopted the Julian(!) calender as late as
1.1.1700(!) (tsar Peter the great), then dropped 13 days at the start of
february 1918(!) to switch to Gregorian.

I think they were the last to do it, and nowadays nobody uses the Julian
calender any more.
--
Kai Henningsen  Internet: kh@ms.maus.de
Muenster         UUCP: any_backbone_that_knows_domains!ms.maus.de!kh
Germany         Fido: kh%maus ms, 2:242/2.6 or Kai Henningsen, 2:242/2.244

cctr132@csc.canterbury.ac.nz (Nick FitzGerald, CSC, Uni. of Canterbury, NZ) (06/08/91)

In article <1991Jun6.083418.9559@ulrik.uio.no>, oep@gi.uio.no
(Oeyvind Pedersen) writes:
> The Julian calendar HAD leap years.  The problem was that it had too
> many - 25 in each century,
> while the Gregorian calendar has 24.25, that is 24 in three centuries
> and 25 in the fourth.
> That makes an average year 365.2425 days long instead of 365.25, while
> the "real" year, i.e
> the time the earth uses in one lap is about 365.2422 days.
 
I know this is getting way off-topic for this group, but the obvious
question now arises:

What happens to these "additional" .0003 days?

Do they just accumulate, putting us further and further out of kilter
but more slowly than the excessive Julian leap years?

I've heard of "leap seconds" (yeah, no kidding) - are these anything
to do with it?

---------------------------------------------------------------------------
 Nick FitzGerald, PC Applications Consultant, CSC, Uni of Canterbury, N.Z. 
 Internet: n.fitzgerald@csc.canterbury.ac.nz        Phone: (64)(3) 642-337 

acm@Sun.COM (Andrew MacRae) (06/11/91)

In article <baillie.676098437@mullauna>, baillie@mullauna.cs.mu.OZ.AU (Stephen Baillie) writes:
> The year was out of sync with the sun by 11 days, so at the same time as
> introducing leap years they cut a few days to make things line up again.
> Caused quite a stir among the superstitious peasants who thought they
> were losing a few days out of their lives!

As the one who first mentioned the dropping of 11 days from the calendar, I
should also mention that (as several people have emailed me to say) the
year that England and its colonies dropped 11 days from September was 1752,
not 1722 as I had misremembered.

It caused more that just a stir among superstitious peasants.  It seems that
landlords felt justified in collecting a full month's rent while employers felt
just as justified in not paying for those 11 days!  There were several days
of rioting with people in the street shouting 'Give us back our days!'.

It all goes to show just how fluid our calendars are.  England dropped
those 11 days in 1752.  Other countries dropped them at other times.  Those of
you out there trying to create the 'perfect' formula for calculating leap year
should remember to take into account what country the calculation is for.

						Andrew MacRae
						

DAVID@ches.cs.vims.edu (06/11/91)

Where do the elusive 0.0003 days go? I quote from "Tables of
Physical and Chemical Constants", G.W.C.Kaye & T.H.Laby, Longmans.
"The mean length of a year in this [the Gregorian] calendar is thus
365.2425 days, which is so near the present actual value that the
date when it will appear to future generations expedient to replace
one further Leap Year by an ordinary one is not yet clearly
specifiable."

The "leap seconds" have to do with the varying rate of rotation of
the _earth_ and keep the solar day in synchronism with the standard
atomic clocks. Leap years, on the other hand, have to do with the
time taken for the earth to orbit the sun.

Another nasty wrinkle about the calendar is that before the 1700's,
the year changed at dates different from January 1. Which day
dependent on which country you were in and even in one country
things changed over time. In England, for a while, things were
standardized so that March 25 (one of the quarter days) began the
year, thus March 24, 1666 was followed by March 25, 1667.
On tombstones you sometimes see dates like January 25, 1650/51.

David Evans, Virginia Institute of Marine Science
DAVID@CHES.CS.VIMS.EDU

dmurdoch@watstat.waterloo.edu (Duncan Murdoch) (06/11/91)

In article <4331@jethro.Corp.Sun.COM> acm@Sun.COM (Andrew MacRae) writes:
>
>It all goes to show just how fluid our calendars are.  England dropped
>those 11 days in 1752.  Other countries dropped them at other times.  Those of
>you out there trying to create the 'perfect' formula for calculating leap year
>should remember to take into account what country the calculation is for.

One other weird complication:  before England made the calendar change, years
ran from March to February, not January to December.  This makes it really
hard to know exactly when certain people (e.g. Thomas Bayes) were born:
if they died after the calendar change, but were said to have been born
in February 1701, was that before or after March 1701?  And, more to
the point of the subject heading (but still not much to do with Pascal; 
sorry), do programs calculating leap years take into account that there was
no February in 1752 in England?  (Or was there?)

Duncan Murdoch

mowl@pippin.cc.flinders.edu.au (Wolfgang Lieff) (06/11/91)

In article <4331@jethro.Corp.Sun.COM> acm@Sun.COM (Andrew MacRae) writes:
>
>It all goes to show just how fluid our calendars are.  England dropped
>those 11 days in 1752.  Other countries dropped them at other times.  Those of
>you out there trying to create the 'perfect' formula for calculating leap year
>should remember to take into account what country the calculation is for.
>
To come back to programming - I think it's clear now, that the 'perfect'
leap year function would not be a mathematical one but a communications
program dialing up a 'national time and date standard service'. And still,
how do we take care of the future ? What about the change to the decimal
(ten month/year) system in 3291 ?

Have fun,
Wolfgang

Wolfgang Lieff , mowl@cc.flinders.edu.au

jfh@vax.oxford.ac.uk (06/11/91)

The Julian-Gregorian transition certainly depends on what country you're
thinking of; it can depend on what part of what country (e.g. Alaska, which
changed when USA bought it from Russia). See the Explanatory Supplement to
the Nautical Almanac and Astronomical Ephemeris (or is it the ES to the AE
and NA - I don't have a copy by me) for a long list. Of course real computer
people will have programmed the dates of Easter (both Western and Orthodox),
Passover, Ramadan, ... as well.