3 # show sunrise and sunset times for each callsign or prefix entered
5 # 1999/11/9 Steve Franke K9AN
6 # 2000/10/27 fixed bug involving degree to radian conversion.
7 # 2001/09/15 accept prefix/call and number of days from today (+ or -).
8 # e.g. sh/moon 2 w0 w9 shows rise/set 2 days hence for w0, w9
9 # sh/moon w0 w9 2 same thing
10 # az and el are shown only when day offset is zero (i.e. today).
12 my ($self, $line) = @_;
13 my @f = split /\s+/, $line;
21 while ($f = shift @f){
23 ($n_offset) = $f =~ /^([-+]?\d+)$/;
28 $n_offset = 0 unless defined $n_offset;
29 $n_offset = 0 if $n_offset > 365; # can request moon rise/set up to 1 year ago or from now...
30 $n_offset = 0 if $n_offset < -365;
32 my ($lat, $lon); # lats and longs in radians
33 my ($sec, $min, $hr, $day, $month, $yr) = (gmtime($main::systime+$n_offset*24*60*60))[0,1,2,3,4,5];
42 my $user = DXUser::get_current(uc $l);
43 if ($user && $user->lat && $user->long) {
44 push @in, [$user->qth, $user->lat, -$user->long, uc $l ];
47 my @ans = Prefix::extract($l);
54 push @in, [ $a->name, $lat, $lon, $pre ];
59 if ($self->user->lat && $self->user->long) {
60 push @in, [$self->user->qth, $self->user->lat, -$self->user->long, $self->call ];
62 push @in, [$main::myqth, $main::mylatitude, -$main::mylongitude, $main::mycall ];
67 push @out, $self->msg('sun_with_azel');
69 push @out, $self->msg('sun');
73 my ($dawn, $rise, $set, $dusk, $az, $dec )=Sun::rise_set($yr,$month,$day,$hr,$min,$l->[1],$l->[2],0);
75 $l->[3] =~ s{(-\d+|/\w+)$}{};
77 push @out,sprintf("%-6.6s %-30.30s %02d/%02d/%4d %s %s %6.1f %6.1f", $l->[3], $l->[0], $day, $month, $yr, $rise, $set, $az, $dec);
79 push @out,sprintf("%-6.6s %-30.30s %02d/%02d/%4d %s %s", $l->[3], $l->[0], $day, $month, $yr, $rise, $set);