diff options
-rwxr-xr-x | rhimport-sm | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/rhimport-sm b/rhimport-sm index b077249..c61e3f9 100755 --- a/rhimport-sm +++ b/rhimport-sm @@ -82,12 +82,14 @@ if($curweek < 1 || $curweek > 4) { exit 1; } -if($curweek != 1 && $curweek != 4) { +my @today = Date::Calc::Today(); +my $dow = Date::Calc::Day_of_Week(@today); +if(($curweek != 1 && $curweek != 4) || + ($curweek == 1 && $dow > 3) || + ($curweek == 4 && $dow <= 3)) { $dbh->disconnect(); exit 0; } - -my @today = Date::Calc::Today(); print "today: " . Date::Calc::Date_to_Text(@today) . "\n"; my @import_date = Date::Calc::Standard_to_Business(@today); @@ -101,7 +103,7 @@ print "day of next Radio Helsinki broadcast: " . Date::Calc::Date_to_Text(@impor my @broadcast_date = Date::Calc::Nth_Weekday_of_Month_Year($import_date[0], $import_date[1], 3, 1); if(Date::Calc::Delta_Days(@broadcast_date, @import_date) <= 0) { my @tmp_date = Date::Calc::Add_Delta_YM(@broadcast_date, 0, -1); - @broadcast_date = Date::Calc::Nth_Weekday_of_Month_Year($tmp_date[0], $tmp_date[1], 2, 3); + @broadcast_date = Date::Calc::Nth_Weekday_of_Month_Year($tmp_date[0], $tmp_date[1], 3, 1); } print "day of latest original broadcast before next Radio Helsinki broadcast: " . Date::Calc::Date_to_Text(@broadcast_date) . "\n"; @@ -113,7 +115,7 @@ if(Date::Calc::Delta_Days(@broadcast_date, @today) <= 0) { my $id = sprintf("%04d-%02d-%02d", $import_date[0], $import_date[1], $import_date[2]); my $bd = sprintf("%04d-%02d-%02d", $broadcast_date[0], $broadcast_date[1], $broadcast_date[2]); -my $bdfile = sprintf("%04d-%02d-%02", $broadcast_date[0], $broadcast_date[1], $broadcast_date[2]); +my $bdfile = sprintf("%04d-%02d-%02d", $broadcast_date[0], $broadcast_date[1], $broadcast_date[2]); print "looking for files from $bd in RSS Feed\n"; print " -> $RSS_URL\n"; |