[freeside-commits] freeside/rt/lib/RTx Calendar.pm,1.1,1.2
Ivan,,,
ivan at wavetail.420.am
Wed May 19 12:04:54 PDT 2010
Update of /home/cvs/cvsroot/freeside/rt/lib/RTx
In directory wavetail.420.am:/tmp/cvs-serv24842/lib/RTx
Modified Files:
Calendar.pm
Log Message:
week view on calendars from Sunday -> Saturday
Index: Calendar.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/lib/RTx/Calendar.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- Calendar.pm 19 May 2010 02:32:00 -0000 1.1
+++ Calendar.pm 19 May 2010 19:04:52 -0000 1.2
@@ -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;
}
More information about the freeside-commits
mailing list