diff options
| author | ivan <ivan> | 2010-05-19 19:04:52 +0000 | 
|---|---|---|
| committer | ivan <ivan> | 2010-05-19 19:04:52 +0000 | 
| commit | d5933aea7be7beddc995fb35cdd034231d2c515f (patch) | |
| tree | bbef4c6faa11cdc44c3b966cd330d173006ecb33 /rt/lib/RTx/Calendar.pm | |
| parent | 1a7887345cd2dec240533a9323eaf8d858d5fecb (diff) | |
week view on calendars from Sunday -> Saturday
Diffstat (limited to 'rt/lib/RTx/Calendar.pm')
| -rw-r--r-- | rt/lib/RTx/Calendar.pm | 15 | 
1 files changed, 9 insertions, 6 deletions
| diff --git a/rt/lib/RTx/Calendar.pm b/rt/lib/RTx/Calendar.pm index 515bd4810..20568e853 100644 --- a/rt/lib/RTx/Calendar.pm +++ b/rt/lib/RTx/Calendar.pm @@ -1,33 +1,36 @@  package RTx::Calendar;  use strict; +use base qw( Exporter );  use DateTime;  use DateTime::Set;  our $VERSION = "0.07"; -sub FirstMonday { -    my ($year, $month) = (shift, shift); +our @EXPORT_OK = qw( FirstDay LastDay ); + +sub FirstDay { +    my ($year, $month, $matchday) = @_;      my $set = DateTime::Set->from_recurrence(  	next => sub { $_[0]->truncate( to => 'day' )->subtract( days => 1 ) }      );      my $day = DateTime->new( year => $year, month => $month ); -    $day = $set->next($day) while $day->day_of_week != 1; +    $day = $set->next($day) while $day->day_of_week != $matchday;      $day;  } -sub LastSunday { -    my ($year, $month) = (shift, shift); +sub LastDay { +    my ($year, $month, $matchday) = @_;      my $set = DateTime::Set->from_recurrence(  	next => sub { $_[0]->truncate( to => 'day' )->add( days => 1 ) }      );      my $day = DateTime->last_day_of_month( year => $year, month => $month ); -    $day = $set->next($day) while $day->day_of_week != 7; +    $day = $set->next($day) while $day->day_of_week != $matchday;      $day;  } | 
