2 # various julian date calculations
4 # Copyright (c) - 1998 Dirk Koopman G1TLH
15 my ($pkg, $year, $thing) = @_;
16 return bless [$year, $thing], ref($pkg)||$pkg;
22 return $old->alloc(@$old);
28 return $a->[1] - $b->[1] if ($a->[0] == $b->[0]);
29 return $a->[0] - $b->[0];
47 my @days = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
53 return ($year % 4 == 0 && ($year % 100 != 0 || $year % 400 == 0)) ? 1 : 0;
60 my ($year, $day) = (gmtime($t))[5,7];
62 return $pkg->SUPER::alloc($year, $day+1);
65 # take a julian date and subtract a number of days from it, returning the julian date
68 my ($old, $amount) = @_;
69 my $self = $old->copy;
70 my $diny = _isleap($self->[0]) ? 366 : 365;
71 $self->[1] -= $amount;
72 while ($self->[1] <= 0) {
75 $diny = _isleap($self->[0]) ? 366 : 365;
82 my ($old, $amount) = @_;
83 my $self = $old->copy;
84 my $diny = _isleap($self->[0]) ? 366 : 365;
85 $self->[1] += $amount;
86 while ($self->[1] > $diny) {
89 $diny = _isleap($self->[0]) ? 366 : 365;
94 package Julian::Month;
103 my ($mon, $year) = (gmtime($t))[4,5];
105 return $pkg->SUPER::alloc($year, $mon+1);
108 # take a julian month and subtract a number of months from it, returning the julian month
111 my ($old, $amount) = @_;
112 my $self = $old->copy;
114 $self->[1] -= $amount;
115 while ($self->[1] <= 0) {
124 my ($old, $amount) = @_;
125 my $self = $old->copy;
127 $self->[1] += $amount;
128 while ($self->[1] > 12) {