2 # various julian date calculations
4 # Copyright (c) - 1998 Dirk Koopman G1TLH
14 use vars qw($VERSION $BRANCH);
15 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
16 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ ) || 0;
17 $main::build += $VERSION;
18 $main::branch += $BRANCH;
23 my ($pkg, $year, $thing) = @_;
24 return bless [$year, $thing], ref($pkg)||$pkg;
30 return $old->alloc(@$old);
36 return $a->[1] - $b->[1] if ($a->[0] == $b->[0]);
37 return $a->[0] - $b->[0];
55 my @days = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
61 return ($year % 4 == 0 && ($year % 100 != 0 || $year % 400 == 0)) ? 1 : 0;
68 my ($year, $day) = (gmtime($t))[5,7];
70 return $pkg->SUPER::alloc($year, $day+1);
73 # take a julian date and subtract a number of days from it, returning the julian date
76 my ($old, $amount) = @_;
77 my $self = $old->copy;
78 my $diny = _isleap($self->[0]) ? 366 : 365;
79 $self->[1] -= $amount;
80 while ($self->[1] <= 0) {
83 $diny = _isleap($self->[0]) ? 366 : 365;
90 my ($old, $amount) = @_;
91 my $self = $old->copy;
92 my $diny = _isleap($self->[0]) ? 366 : 365;
93 $self->[1] += $amount;
94 while ($self->[1] > $diny) {
97 $diny = _isleap($self->[0]) ? 366 : 365;
102 package Julian::Month;
111 my ($mon, $year) = (gmtime($t))[4,5];
113 return $pkg->SUPER::alloc($year, $mon+1);
116 # take a julian month and subtract a number of months from it, returning the julian month
119 my ($old, $amount) = @_;
120 my $self = $old->copy;
122 $self->[1] -= $amount;
123 while ($self->[1] <= 0) {
132 my ($old, $amount) = @_;
133 my $self = $old->copy;
135 $self->[1] += $amount;
136 while ($self->[1] > 12) {