[net.micro.amiga] Date calculation from DateStamp

rokicki@Navajo.ARPA (02/10/86)

*** REPLACE THIS LINE WITH YOUR MASSEUSE ***

Here is a little subroutine that might be of use to some of you
out there---it takes the date in DateStamp form, and converts it
to month/day/year form.  Coming up with this algorithm presented
an interesting puzzle in itself.

By the way, this routine will fail on March 1, 2100.

---------------------------------------------------------------------
char *months[]={"","January","February","March","April","May","June",
        "July","August","September","October","November","December"} ;

main () {
   long v[3] ;
   long n ;
   int m, d, y ;

   DateStamp(v) ;

   n = v[0] - 2251 ;
   y = (4 * n + 3) / 1461 ;
   n -= 1461 * y / 4 ;
   y += 1984 ;
   m = (5 * n + 2) / 153 ;
   d = n - (153 * m + 2) / 5 + 1 ;
   m += 3 ;
   if (m > 12) {
      y++ ;
      m -= 12 ;
   }
   printf("%s %d, %d\n", months[m], d, y) ;
}
-------------------------------------------------------------------
-tom