I'm trying to write a function that will calculate the number of days that exist between two dates, but have been unable to come up with an adequete solution thus far. In the reasearch that I've done, I've seen some methods convert the dates to milliseconds, subtract, then convert back. In others, they've incrimented a count variable, and simple added days to the earlier date until the two dates matched. Unfortunately, neither of these methods seems completely accurate under all conditions, nor do they seem as elegant as you'd hope them to be.
How have you done this calculation before? Is there a common library or standard function that's commonly used for this calculation?
Thanks in advance.