2 # various julian date calculations
4 # Copyright (c) - 1998 Dirk Koopman G1TLH
13 my @days = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
15 # take a unix date and transform it into a julian day (ie (1998, 13) = 13th day of 1998)
19 my ($year, $day) = (gmtime($t))[5,7];
22 return ($year, $day+1);
25 # take a unix and return a julian month from it
29 my ($mon, $year) = (gmtime($t))[4..5];
32 return ($year, $mon + 1);
35 # take a julian date and subtract a number of days from it, returning the julian date
38 my ($year, $day, $amount) = @_;
39 my $diny = isleap($year) ? 366 : 365;
44 $diny = isleap($year) ? 366 : 365;
51 my ($year, $day, $amount) = @_;
52 my $diny = isleap($year) ? 366 : 365;
54 while ($day > $diny) {
57 $diny = isleap($year) ? 366 : 365;
62 # take a julian month and subtract a number of months from it, returning the julian month
65 my ($year, $mon, $amount) = @_;
76 my ($year, $mon, $amount) = @_;
87 my ($y1, $d1, $y2, $d2) = @_;
88 return $d1 - $d2 if ($y1 == $y2);
96 return ($year % 4 == 0 && ($year % 100 != 0 || $year % 400 == 0)) ? 1 : 0;