Re: Days between dates  another solution Message #4 Posted by Palmer O. Hanson, Jr. on 13 Aug 2009, 11:14 p.m., in response to message #1 by Bart (UK)
I noted that the program for days between dates in my HP12C correctly handles the leap year for years divisible by 100 with one exception  the year 4000 when the modified Gregorian calendar calls for that year not to be a leap year. The program in ML20 of the Master Library module for the TI59 operates in the same way. I compared the equations for days between dates on pages 208209 of the HP12C manual with the equations on page 76 of the manual for the TI59 Master Library module and found that they were the same except that the TI59 version has an additional term to take care of the years divisible by 100. For March through December the additional term is
INT(.75(INT(YYYY/100)+1))
For January and February the additional term is the same except that YYYY has been decreased by one. You can look at the ML20 documentation at either Viktor Toth's or Joerg Woerner's site.
I did download the ML20 program, altered it to bypass the last terms and verified that the omission did cause a problem at years divisible by 100 but not divisible by 400.
While looking at all of this I noted that both the HP12C and TI59 programs implement error trapping of the input such as not allowing the number of months to be greater than 12, etc. I don't know how much memory is used in the HP12C for input error trapping. The entire TI59 program for days between dates is 172 steps where 68 of those steps are used for input error trapping.
Bart wrote "Flame me for being pedantic." Here's an example of really being pedantic. Way back when, some purist discovered that input error trapping in the TI59 program limits the number of days of any month to 31, but does not limit the days of the months that do not have 31 days to the lesser number. Thus, the TI59 program will return the number of days between January 1, 1900 and March 3, 1900 as 61 days, but will also return the number of days between January 1, 1900 and February 31, 1900 as 61 days. I suppose someone, but not me, could argue that February 31, 1900 is really the same as March 3, 1900. The HP12C program will indicate "Error 8" if a user tries to enter a February 31 date.
Palmer
