TIP: Click on subject to list as thread! ANSI
echo: public_domain
to: All
from: rowan_crowe
date: 1996-01-19 05:51:24
subject: Leap years

While working on UNIX date formats for MoonRock, I had to write a function
to determine whether a year had 365 or 366 (leap year) days. Determining
whether a given year is a leap year or not seems to be a rather confusing
problem for many people.

The algorithm I have is:

LeapYear if Year Mod 4 = 0

   EXCEPT if Year Mod 100 = 0

       UNLESS Year Mod 1000 = 0

Based on the above, I've written a C callable ASM function to decide
whether it's a leap year. I'm sure it's been done zillions of times in C
too, but here's my particular solution.

I've also included a sample C program to demonstrate it.

Someone PLEASE check its operation thoroughly! I hope I have correctly
understood the algorithm.

(Bear in mind it's 5:51am...)

---
* Origin: Jelly-Bean software development, Melbourne AUST. (3:635/727.1)
SEEN-BY: 50/99 632/103 348 998 633/371 634/384 635/402 503 544 727 638/102
SEEN-BY: 639/252 640/230 690/718 711/401 410 413 430 808 809 934 713/888
SEEN-BY: 800/1 7877/2809
@PATH: 635/727 632/348 635/503 50/99 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.