- my ($expr, $dayfrom, $dayto, $from, $to) = @_;
- my $eval;
- my @out;
- my $ref;
- my $i;
- my $count;
- my @today = Julian::unixtoj(time);
- my @fromdate;
- my @todate;
-
- if ($dayfrom > 0) {
- @fromdate = Julian::sub(@today, $dayfrom);
- } else {
- @fromdate = @today;
- $dayfrom = 0;
- }
- if ($dayto > 0) {
- @todate = Julian::sub(@fromdate, $dayto);
- } else {
- @todate = Julian::sub(@fromdate, $maxdays);
- }
- if ($from || $to) {
- $to = $from + $maxspots if $to - $from > $maxspots || $to - $from <= 0;
- } else {
- $from = 0;
- $to = $defaultspots;
- }
-
- $expr =~ s/\$f(\d)/\$ref->[$1]/g; # swap the letter n for the correct field name
+ my ($expr, $dayfrom, $dayto, $from, $to, $hint) = @_;
+ my $eval;
+ my @out;
+ my $ref;
+ my $i;
+ my $count;
+ my @today = Julian::unixtoj(time());
+ my @fromdate;
+ my @todate;
+
+ $dayfrom = 0 if !$dayfrom;
+ $dayto = $maxdays unless $dayto;
+ $dayto = $dayfrom + $maxdays if $dayto < $dayfrom;
+ @fromdate = Julian::sub(@today, $dayfrom);
+ @todate = Julian::sub(@fromdate, $dayto);
+ $from = 0 unless $from;
+ $to = $defaultspots unless $to;
+ $hint = $hint ? "next unless $hint" : "";
+ $expr = "1" unless $expr;
+
+ $to = $from + $maxspots if $to - $from > $maxspots || $to - $from <= 0;
+
+ $expr =~ s/\$f(\d)/\$ref->[$1]/g; # swap the letter n for the correct field name
+ # $expr =~ s/\$f(\d)/\$spots[$1]/g; # swap the letter n for the correct field name