2 # various julian date calculations
4 # Copyright (c) - 1998 Dirk Koopman G1TLH
17 my @days = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
19 # take a unix date and transform it into a julian day (ie (1998, 13) = 13th day of 1998)
23 my ($year, $day) = (gmtime($t))[5,7];
26 $year += ($year < 50) ? 2000 : 1900;
28 return ($year, $day+1);
31 # take a unix and return a julian month from it
35 my ($mon, $year) = (gmtime($t))[4..5];
39 # take a julian date and subtract a number of days from it, returning the julian date
42 my ($year, $day, $amount) = @_;
43 my $diny = isleap($year) ? 366 : 365;
48 $diny = isleap($year) ? 366 : 365;
55 my ($year, $day, $amount) = @_;
56 my $diny = isleap($year) ? 366 : 365;
58 while ($day > $diny) {
61 $diny = isleap($year) ? 366 : 365;
66 # take a julian month and subtract a number of months from it, returning the julian month
69 my ($year, $mon, $amount) = @_;
80 my ($year, $mon, $amount) = @_;
91 my ($y1, $d1, $y2, $d2) = @_;
92 return $d1 - $d2 if ($y1 == $y2);
100 return ($year % 4 == 0 && ($year % 100 != 0 || $year % 400 == 0)) ? 1 : 0;