X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fshow%2Fmoon.pl;h=1bc61479ca8cae031540d6f7274272631872a60e;hb=ab811a0c902225075a9bd69749f65594079433a9;hp=b1e4feb4fc0d64780845c441a0e2a1a66fc0e7c1;hpb=5dfbac3cf881abb6e30523ae0bc8bcda510897f9;p=spider.git diff --git a/cmd/show/moon.pl b/cmd/show/moon.pl index b1e4feb4..1bc61479 100644 --- a/cmd/show/moon.pl +++ b/cmd/show/moon.pl @@ -1,17 +1,38 @@ #!/usr/bin/perl # -# show sunrise and sunset times for each callsign or prefix entered +# show moonrise and moonset times for each callsign or prefix entered # # 1999/11/9 Steve Franke K9AN -# +# 2000/10/27 fixed bug involving degree to radian conversion. +# 2001/09/15 accept prefix/call and number of days from today (+ or -). +# e.g. sh/moon 2 w0 w9 shows rise/set 2 days hence for w0, w9 +# sh/moon w0 w9 2 same thing +# az and el are shown only when day offset is zero (i.e. today). my ($self, $line) = @_; -my @list = split /\s+/, $line; +my @f = split /\s+/, $line; -my $l; my @out; +my $f; +my $l; +my $n_offset; +my @list; +my ($rise, $set, $az, $dec, $loss, $ifrac); + +while ($f = shift @f){ + if(!$n_offset){ + ($n_offset) = $f =~ /^([-+]?\d+)$/; + next if $n_offset; + } + push @list, $f; +} +$n_offset = 0 unless defined $n_offset; +$n_offset = 0 if $n_offset > 365; # can request moon rise/set up to 1 year ago or from now... +$n_offset = 0 if $n_offset < -365; + my ($lat, $lon); # lats and longs in radians -my ($sec, $min, $hr, $day, $month, $yr) = (gmtime($main::systime))[0,1,2,3,4,5]; +my ($sec, $min, $hr, $day, $month, $yr) = (gmtime($main::systime+$n_offset*24*60*60))[0,1,2,3,4,5]; + $month++; $yr += 1900; @@ -19,9 +40,9 @@ my @in; if (@list) { foreach $l (@list) { - my $user = DXUser->get_current(uc $l); + my $user = DXUser::get_current(uc $l); if ($user && $user->lat && $user->long) { - push @in, [$user->qth, $user->lat * $d2r, $user->long * -$d2r, uc $l ]; + push @in, [$user->qth, $user->lat, -$user->long, uc $l ]; } else { # prefixes ---> my @ans = Prefix::extract($l); @@ -43,14 +64,20 @@ if (@list) { } } -push @out, $self->msg('moon'); +if( !$n_offset ) { + push @out, $self->msg('moon_with_azel'); +} else { + push @out, $self->msg('moon'); +} foreach $l (@in) { - my ($rise, $set, $az, $dec, $loss )=Sun::rise_set($yr,$month,$day,$hr,$min,$l->[1],$l->[2],1); + ($rise, $set, $az, $dec, $loss, $ifrac)=Sun::rise_set($yr,$month,$day,$hr,$min,$l->[1],$l->[2],1); $l->[3] =~ s{(-\d+|/\w+)$}{}; - push @out,sprintf("%-6.6s %-30.30s %s %s %6.1f %6.1f %3.1f", $l->[3], $l->[0], $rise, $set, $az, $dec, $loss); + if( !$n_offset ) { + 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); + } else { + push @out,sprintf("%-6.6s %-30.30s %02d/%02d/%4d %s %s", $l->[3], $l->[0], $day, $month, $yr, $rise, $set); + } } - - - +push @out,sprintf("Illuminated fraction of the Moon's disk is %4.2f",$ifrac); return (1, @out);