2 # various julian date calculations
4 # Copyright (c) - 1998 Dirk Koopman G1TLH
16 my @days = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
18 # take a unix date and transform it into a julian day (ie (1998, 13) = 13th day of 1998)
22 my ($year, $day) = (gmtime($t))[5,7];
25 $year += ($year < 50) ? 2000 : 1900;
27 return ($year, $day+1);
30 # take a unix and return a julian month from it
34 my ($mon, $year) = (gmtime($t))[4..5];
36 $year += ($year < 50) ? 2000 : 1900;
38 return ($year, $mon + 1);
41 # take a julian date and subtract a number of days from it, returning the julian date
44 my ($year, $day, $amount) = @_;
45 my $diny = isleap($year) ? 366 : 365;
50 $diny = isleap($year) ? 366 : 365;
57 my ($year, $day, $amount) = @_;
58 my $diny = isleap($year) ? 366 : 365;
60 while ($day > $diny) {
63 $diny = isleap($year) ? 366 : 365;
68 # take a julian month and subtract a number of months from it, returning the julian month
71 my ($year, $mon, $amount) = @_;
82 my ($year, $mon, $amount) = @_;
93 my ($y1, $d1, $y2, $d2) = @_;
94 return $d1 - $d2 if ($y1 == $y2);
102 return ($year % 4 == 0 && ($year % 100 != 0 || $year % 400 == 0)) ? 1 : 0;