What do you need this for? Are you going to use it somewhere in a program? There might be alternate ways to do it.
This is in java,
Code:
private static int daysSince1900( int day, int month, int year ) {
int fullYears = year - 1900;
int leapYears = ( year - 1901 ) / 4; // To calculate *full* leap years, centuries,
int centuries = ( year - 1901 ) / 100; // etc. since 1900, I count from 1901 (or 1601,
int fourCenturies = ( year - 1601 ) / 400; // for quadruple centuries) to avoid counting the current year, which isn't full yet.
return fullYears * 365 + leapYears - centuries + fourCenturies
+ daysIntoYear( month, year )
+ day - 1;
}
Bookmarks