Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site Navajo.ARPA Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!glacier!Navajo!rokicki From: rokicki@Navajo.ARPA Newsgroups: net.micro.amiga Subject: Date calculation from DateStamp Message-ID: <358@Navajo.ARPA> Date: Mon, 10-Feb-86 15:25:45 EST Article-I.D.: Navajo.358 Posted: Mon Feb 10 15:25:45 1986 Date-Received: Wed, 12-Feb-86 07:41:24 EST Distribution: net Organization: Stanford University Lines: 35 *** 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