diff options
author | Christian Pointner <equinox@spreadspace.org> | 2016-04-15 20:43:20 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2016-04-15 20:43:20 (GMT) |
commit | eec0aa47e2d9ee49f57160b238a70cc81aa3f744 (patch) | |
tree | 76da91d90bcc903fb75e51ab185ab72f91328eb5 /lib/RHRD/utils.pm | |
parent | d1016e1e09bf460ede1ac49e91650351b3aff4a4 (diff) |
added some more checks: dow, week-rhythm...
Diffstat (limited to 'lib/RHRD/utils.pm')
-rwxr-xr-x | lib/RHRD/utils.pm | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/RHRD/utils.pm b/lib/RHRD/utils.pm index fbc3933..7f060e9 100755 --- a/lib/RHRD/utils.pm +++ b/lib/RHRD/utils.pm @@ -32,6 +32,7 @@ use JSON; sub get_rd_week { + my ($time) = @_; # # This computes the current Rivendell Week based on the number # of weeks since epoch. @@ -48,10 +49,12 @@ sub get_rd_week # with 0 meaning Week 1. So add 1 to that number and you will get # the current RD week. # - my $now = DateTime->now(); + if(!defined($time)) { + $time = 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 $tz_offset = $tz->offset_for_datetime($time); + my $sEpoch = $time->epoch() + $tz_offset; my $week = floor(((($sEpoch + 259200)/604800) + 2) % 4) + 1; return $week; |