[comp.sys.handhelds] Leap Years

scottb@hpcvia.CV.HP.COM (Scott_Burke) (08/10/90)

Hi.

Would someone please verify that I have the leap year algorithm correct:

  February has 28 days UNLESS the year is divisible by   4, in which case
  February has 29 days UNLESS the year is divisible by 100, in which case
  February has 28 days UNLESS the year is divisible by 400, in which case
  February has 29 days.

Sound good?


scott.

math1i7@jetson.uh.edu (08/10/90)

In article <31210047@hpcvia.CV.HP.COM>, scottb@hpcvia.CV.HP.COM (Scott_Burke) writes:
> 
> Would someone please verify that I have the leap year algorithm correct:
> 
>   February has 28 days UNLESS the year is divisible by   4, in which case
>   February has 29 days UNLESS the year is divisible by 100, in which case
>   February has 28 days UNLESS the year is divisible by 400, in which case
>   February has 29 days.

Scott, I have never heard about the 100 and 400 year rules... I had always
assumed that:
	IF 0 year 4 MOD == THEN 28 ELSE 29 END
Are the 100 and 400 year rules there to correct for the fraction of
a second off each year is from a "true" 365 or 366 days?

Gordon

jc@atcmp.nl (Jan Christiaan van Winkel) (08/12/90)

From article <6758.26c2a07b@jetson.uh.edu>, by math1i7@jetson.uh.edu:
) In article <31210047@hpcvia.CV.HP.COM>, scottb@hpcvia.CV.HP.COM (Scott_Burke) writes:
)> 
)> Would someone please verify that I have the leap year algorithm correct:
)> 
)>   February has 28 days UNLESS the year is divisible by   4, in which case
)>   February has 29 days UNLESS the year is divisible by 100, in which case
)>   February has 28 days UNLESS the year is divisible by 400, in which case
)>   February has 29 days.
) 
) Scott, I have never heard about the 100 and 400 year rules... I had always
) assumed that:
) 	IF 0 year 4 MOD == THEN 28 ELSE 29 END
) Are the 100 and 400 year rules there to correct for the fraction of
) a second off each year is from a "true" 365 or 366 days?
) 
) Gordon
Scott was right. I.e. 1904, 1908, 1912,... were leappyears,
1900, 2100, 2200, 2300 are not but 2000 is. (Ever wonder why 
electronic watches keep the correct date until 2099...:-)
JC
-- 
___  __  ____________________________________________________________________
   |/  \   Jan Christiaan van Winkel      Tel: +31 80 566880  jc@atcmp.nl
   |       AT Computing   P.O. Box 1428   6501 BK Nijmegen    The Netherlands
__/ \__/ ____________________________________________________________________

greg@blister.Solbourne.COM (Greg Foisy) (08/12/90)

In article <648@atcmpe.atcmp.nl> jc@atcmp.nl (Jan Christiaan van Winkel) writes:
>From article <6758.26c2a07b@jetson.uh.edu>, by math1i7@jetson.uh.edu:
>) In article <31210047@hpcvia.CV.HP.COM>, scottb@hpcvia.CV.HP.COM (Scott_Burke) writes:
>)> 
>)> Would someone please verify that I have the leap year algorithm correct:
>)> 
>)>   February has 28 days UNLESS the year is divisible by   4, in which case
>)>   February has 29 days UNLESS the year is divisible by 100, in which case
>)>   February has 28 days UNLESS the year is divisible by 400, in which case
>)>   February has 29 days.
>) 
>) Scott, I have never heard about the 100 and 400 year rules... I had always
>) assumed that:
>) 	IF 0 year 4 MOD == THEN 28 ELSE 29 END
>) Are the 100 and 400 year rules there to correct for the fraction of
>) a second off each year is from a "true" 365 or 366 days?
>) 
>) Gordon
>Scott was right. I.e. 1904, 1908, 1912,... were leappyears,
>1900, 2100, 2200, 2300 are not but 2000 is. (Ever wonder why 
>electronic watches keep the correct date until 2099...:-)

	Well, he was kinda right... quoting from parts of the Gregorian Year
	Table:

	Leap Years
	----------
	Every 4th year but only those centesimal years divisible by 400.

	FYI, the rest of the info that resides in a year table:

	Year Chronology
	---------------
	From Roman year 754, the year immediately following the birth of Christ
	as placed by Dionysus Exiguus in the 753rd year of Rome

	Year Begins
	-----------
	Ten days after the winter solstice

	Number of Days
	--------------
	Common Years	365
	Leap years	366

-- 
	"The most overlooked advantage to owning a computer is that if they
	 foul up there's no law against wacking them around a little."

							-- Porterfield

akcs.kevin@hpcvbbs.UUCP (Kevin Jessup) (08/14/90)

Here is a handy leap year function for your 28 or 48!
 
<< -> y << y 4 MOD NOT y 100 MOD AND y 400 MOD NOT OR >> >>
 
Place the year on the stack.  Execute the function.
Output is 1 if a leap year, else 0.
 
Kevin Jessup
Marquette Electronics
Milwaukee, WI
(414) 362-2020
"Newton hated figs."

jrl@images1.Waterloo.NCR.COM (john Latala) (08/15/90)

In article <6758.26c2a07b@jetson.uh.edu> math1i7@jetson.uh.edu writes:
>In article <31210047@hpcvia.CV.HP.COM>, scottb@hpcvia.CV.HP.COM (Scott_Burke) writes:
>> 
>> Would someone please verify that I have the leap year algorithm correct:
>> 
>>   February has 28 days UNLESS the year is divisible by   4, in which case
>>   February has 29 days UNLESS the year is divisible by 100, in which case
>>   February has 28 days UNLESS the year is divisible by 400, in which case
>>   February has 29 days.
>
>Scott, I have never heard about the 100 and 400 year rules... I had always
>assumed that:
>	IF 0 year 4 MOD == THEN 28 ELSE 29 END
>Are the 100 and 400 year rules there to correct for the fraction of
>a second off each year is from a "true" 365 or 366 days?

There's a neat pair of books about doing astronomical calculations:

	Practical Astronomy with your Calculator
and
	Practical Astronomy with your PC

both books are by Peter Duffet-Smith.

They have a nice section talking about date and time routines for
converting from 'normal' date to the astronomical Julian Date. In the
one section there's a nice disscussion about all the date stuff:

" ... Before 5th October, 1582 the Julian calendar was in general use in
Europe. By this calendar there were 365 days in each year except if the
year number was divisible by 4, then there were 366. This variation was
incorporated to make some allowance for the fact that the length of the
year, i.e. the time taken by the Earth to complete one orbit around the
Sun, is not a whole number of days. The length of the tropical year is
in fact 365.2422 days, and by adopting the convention of a leap year
every fourth year, the average Julian year is 365.25 days. This worked
quite well for hundreds of years, until 1582 astronomers were worried by
the accumulate error which had built up through the difference between
the tropical year and the Julian year. Accordingly, Pope Gregory decreed
that the dates 5-14th October 1582 inclusive were to be abolished (to
readjust the seasons to their correct positions) and that years ending
in two zeros (1700, 1800, etc.) were only leap years if divisible by
400. By this device, 400 civil years contained (400 * 365) + 100 - 3 =
146097 days. The average length of the civil year was then 146097 / 400
= 365.2425 days, a much better approximation to the length of the
tropical year."

Quoted without permission from "Practical Astronomy with your PC" by
Peter Duffet-Smith, Cambridge University Press, ISBN 0-521-38995-X
(paperback), Second Edition, Pages 15-16.

Any spelling errors and/or typos are probably mine......
--
john.Latala@Waterloo.NCR.COM

scott@discus.Sun.COM (Scott Pett Customer Training Instructor) (08/15/90)

 thought the days abolished were in September 1752 and were the 3rd to
the 13th. Or has UNIX cal command been wrong all this time.... :-)

discus% cal 9 1752
   September 1752
 S  M Tu  W Th  F  S
       1  2 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30



discus% 

Regards
SP

bmp@hp-ptp.HP.COM (Brian Perkin) (08/21/90)

There is a published algorithm for this in the collected algorithms
of the ACM available in any computing science or math library.
Why not use it rather than reinvent it?

Brian Perkin

campbelr@hpclrec.HP.COM (Bob Campbell) (08/21/90)

The days missing in 1752 are for England and her colonies only.  (That
is when they changed calendars, they did not create the new one)
-----------------------------------------------------------------------------
Bob Campbell                Some times I wish that I could stop you from 
campbelr@hpda.hp.com        talking, when I hear the silly things you say.
Hewlett Packard                                    - Elvis Costello