-foreach $l (@list) {
- # prefixes --->
- my @ans = Prefix::extract($l);
- next if !@ans;
- my $pre = shift @ans;
- my $a;
- foreach $a (@ans) {
- $lat = $a->{lat};
- $lon = $a->{long};
- $lat *= $d2r;
- $lon *= -$d2r;
- my $string=Sun::riseset($yr,$month,$day,$lat,$lon);
- push @out,sprintf("%-2s %s %s",$pre,$a->name(),$string);
- $l="";
+my @in;
+
+if (@list) {
+ foreach $l (@list) {
+ my $user = DXUser::get_current(uc $l);
+ if ($user && $user->lat && $user->long) {
+ push @in, [$user->qth, $user->lat, -$user->long, uc $l ];
+ } else {
+ # prefixes --->
+ my @ans = Prefix::extract($l);
+ next if !@ans;
+ my $pre = shift @ans;
+ my $a;
+ foreach $a (@ans) {
+ $lat = $a->{lat};
+ $lon = -$a->{long};
+ push @in, [ $a->name, $lat, $lon, $pre ];
+ }
+ }
+ }
+} else {
+ if ($self->user->lat && $self->user->long) {
+ push @in, [$self->user->qth, $self->user->lat, -$self->user->long, $self->call ];
+ } else {
+ push @in, [$main::myqth, $main::mylatitude, -$main::mylongitude, $main::mycall ];
+ }
+}
+
+if ( !$n_offset ) {
+ push @out, $self->msg('sun_with_azel');
+} else {
+ push @out, $self->msg('sun');
+}
+
+foreach $l (@in) {
+ my ($dawn, $rise, $set, $dusk, $az, $dec )=Sun::rise_set($yr,$month,$day,$hr,$min,$l->[1],$l->[2],0);
+
+ $l->[3] =~ s{(-\d+|/\w+)$}{};
+ 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);