From 8c27798a5fa60ed7f0d1babc5391b26b68b9a7e1 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 24 Jul 2015 23:25:25 +0200 Subject: moved get_rd_week to RHRD as well diff --git a/rhimport-rs b/rhimport-rs index 808d36c..71d9e27 100755 --- a/rhimport-rs +++ b/rhimport-rs @@ -80,7 +80,7 @@ if(!$to_cart) { exit 1; } -my $curweek = rhimport::get_rd_week(); +my $curweek = RHRD::utils::get_rd_week(); my $nextweek = $curweek == 4 ? 1 : $curweek + 1; my @today = Date::Calc::Today(); diff --git a/rhimport-sm b/rhimport-sm index 252d72e..e28276f 100755 --- a/rhimport-sm +++ b/rhimport-sm @@ -73,7 +73,7 @@ if(scalar(@allowed_dbs) != 1) { my $dropbox = $allowed_dbs[0]->{'PATH'}; my $to_cart = $allowed_dbs[0]->{'TO_CART'}; -my $curweek = rhimport::get_rd_week(); +my $curweek = RHRD::utils::get_rd_week(); my @today = Date::Calc::Today(); my $dow = Date::Calc::Day_of_Week(@today); diff --git a/rhimport-sv b/rhimport-sv index 840ff20..6056f69 100755 --- a/rhimport-sv +++ b/rhimport-sv @@ -73,7 +73,7 @@ if(scalar(@allowed_dbs) != 1) { my $dropbox = $allowed_dbs[0]->{'PATH'}; my $to_cart = $allowed_dbs[0]->{'TO_CART'}; -my $curweek = rhimport::get_rd_week(); +my $curweek = RHRD::utils::get_rd_week(); my @today = Date::Calc::Today(); my $dow = Date::Calc::Day_of_Week(@today); diff --git a/rhimport.pm b/rhimport.pm index 353b75d..09c5082 100644 --- a/rhimport.pm +++ b/rhimport.pm @@ -30,9 +30,6 @@ use IPC::Open3; use File::Spec; use File::Basename; use URI::Escape; -use POSIX; -use DateTime; -use DateTime::TimeZone; use LWP::Simple; use XML::Feed; @@ -42,33 +39,6 @@ my $ssh_key_file = "$ENV{'HOME'}/.rhimport/import.key"; my $ssh_dir = "/programm/.rhimport"; my $rdimport_wrapper = "/usr/local/bin/dropbox_newfile.pl"; -sub get_rd_week -{ - # - # This computes the current Rivendell Week based on the number - # of weeks since epoch. - # - # Explanation: - # epoch was at 01.01.1970 which was a Thursday. - # Monday in that week is (s-from-epoch + 3*24*60*60) seconds ago. - # This needs to be adjusted by the timezone offset for Europe/Vienna - # which is of course not constant (damn you daylight savings time) - # Divide this by (7*24*60*60) and you get the number of - # weeks since the Monday in the week of epoch adjusted for timezone offsets. - # This week had week number 3 so add an offset of 2 and - # get the modulo of 4. This rounded down gives you the current week - # with 0 meaning Week 1. So add 1 to that number and you will get - # the current RD week. - # - my $now = DateTime->now(); - my $tz = DateTime::TimeZone->new(name => 'Europe/Vienna'); - my $tz_offset = $tz->offset_for_datetime($now); - my $sEpoch = $now->epoch() + $tz_offset; - my $week = floor(((($sEpoch + 259200)/604800) + 2) % 4) + 1; - - return $week; -} - sub fetch_parse_rss { my ($url, $ua_str) = @_; -- cgit v0.10.2