2 # various julian date calculations
4 # Copyright (c) - 1998 Dirk Koopman G1TLH
15 my @days = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
17 # take a unix date and transform it into a julian day (ie (1998, 13) = 13th day of 1998)
21 my ($year, $day) = (gmtime($t))[5,7];
24 $year += ($year < 50) ? 2000 : 1900;
26 return ($year, $day+1);
29 # take a unix and return a julian month from it
33 my ($mon, $year) = (gmtime($t))[4..5];
35 $year += ($year < 50) ? 2000 : 1900;
37 return ($year, $mon + 1);
40 # take a julian date and subtract a number of days from it, returning the julian date
43 my ($year, $day, $amount) = @_;
44 my $diny = isleap($year) ? 366 : 365;
49 $diny = isleap($year) ? 366 : 365;
56 my ($year, $day, $amount) = @_;
57 my $diny = isleap($year) ? 366 : 365;
59 while ($day > $diny) {
62 $diny = isleap($year) ? 366 : 365;
67 # take a julian month and subtract a number of months from it, returning the julian month
70 my ($year, $mon, $amount) = @_;
81 my ($year, $mon, $amount) = @_;
92 my ($y1, $d1, $y2, $d2) = @_;
93 return $d1 - $d2 if ($y1 == $y2);
101 return ($year % 4 == 0 && ($year % 100 != 0 || $year % 400 == 0)) ? 1 : 0;