X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Flib%2FRTx%2FCalendar.pm;h=7ddf186193a452037753fe697cae14ec56b2ab88;hb=cebcd8658ba5f45fc21d59769d591b1418a3fdd2;hp=e297566f06e02eda72bb43ca004b0404582a1927;hpb=fec244eb00508517cd3313f6cf55973c2d2e99cf;p=freeside.git diff --git a/rt/lib/RTx/Calendar.pm b/rt/lib/RTx/Calendar.pm index e297566f0..7ddf18619 100644 --- a/rt/lib/RTx/Calendar.pm +++ b/rt/lib/RTx/Calendar.pm @@ -5,12 +5,13 @@ use base qw( Exporter ); use DateTime; use DateTime::Set; -our $VERSION = "0.14"; +our $VERSION = "0.17"; RT->AddStyleSheets('calendar.css') if RT->can('AddStyleSheets'); -our @EXPORT_OK = qw( FirstDay LastDay ); +our @EXPORT_OK = qw( FirstDay LastDay LastDayOfWeek DatesClauses LocalDate + SearchDefaultCalendar FindTickets ); sub FirstDay { my ($year, $month, $matchday) = @_; @@ -37,6 +38,19 @@ sub LastDay { $day; } +sub LastDayOfWeek { + my ($year, $month, $day, $matchday) = @_; + my $set = DateTime::Set->from_recurrence( + next => sub { $_[0]->truncate( to => 'day' )->add( days => 1 ) } + ); + + my $dt = DateTime->new( year => $year, month => $month, day => $day ); + + $dt = $set->next($dt) while $dt->day_of_week != $matchday; + $dt; + +} + # we can't use RT::Date::Date because it uses gmtime # and we need localtime sub LocalDate { @@ -154,9 +168,8 @@ number based so that you can give those feeds to other people. If you upgrade from 0.02, see next part before. -You need to install those three modules : +You need to install those two modules : - * Date::ICal * Data::ICal * DateTime::Set