Here's a short (44-line) Perl script that will do the job. It's not flexible on the argument format - they have to be yyyy-mm-dd - and it is Perl, but at least it doesn't use a zillion modules. The only module it does use is POSIX, and that's only to get the floor() function; if you aren't going to be dealing with negative years you can get rid of the "use POSIX" line and replace floor(...) with int(...).
-- Mark REED | CNN Internet Technology 1 CNN Center Rm SW0831G | [EMAIL PROTECTED] Atlanta, GA 30348 USA | +1 404 827 4754 -- If you are going to walk on thin ice, you may as well dance.
#!/usr/bin/perl use POSIX; # calculate the number of days between two Gregorian dates if (@ARGV != 2) { die "Usage: $0 yyyy-mm-dd1 yyyy-mm-dd2\n"; } my ($from, $to) = @ARGV; my $from_jd = jd_from_gregorian(split('-',$from)); my $to_jd = jd_from_gregorian(split('-',$to)); print $to_jd - $from_jd, "\n"; exit(0); # Calculate the astronomical Julian Day number as of noon on the given # (year, month, day). In this program we don't really need the # actual JD; any absolute day count would give us the same answer # without the offset. But it doesn't hurt to use a number that's # meaningful in other contexts. sub jd_from_gregorian { my ($year, $month, $day) = @_; my $elapsed_years = $year; # We start counting from March to keep February from screwing # up the math my $months_into_year = $month - 3; if ($months_into_year < 0) { $elapsed_years--; $months_into_year += 12; } my $thirty1sts = floor((7*$months_into_year+7)/12); # JD 1,721,120 began at noon UTC on March 1st, 0 AD (== 1 BC) # in the retrojected Gregorian calendar. return 1_721_120 + $elapsed_years * 365 + floor($elapsed_years/4) - floor($elapsed_years/100) + floor($elapsed_years/400) + $months_into_year * 30 + $thirty1sts + $day - 1; }