projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1a78873
)
week view on calendars from Sunday -> Saturday
author
ivan
<ivan>
Wed, 19 May 2010 19:04:52 +0000
(19:04 +0000)
committer
ivan
<ivan>
Wed, 19 May 2010 19:04:52 +0000
(19:04 +0000)
rt/lib/RTx/Calendar.pm
patch
|
blob
|
history
rt/share/html/Search/Calendar.html
patch
|
blob
|
history
diff --git
a/rt/lib/RTx/Calendar.pm
b/rt/lib/RTx/Calendar.pm
index
515bd48
..
20568e8
100644
(file)
--- a/
rt/lib/RTx/Calendar.pm
+++ b/
rt/lib/RTx/Calendar.pm
@@
-1,33
+1,36
@@
package RTx::Calendar;
use strict;
package RTx::Calendar;
use strict;
+use base qw( Exporter );
use DateTime;
use DateTime::Set;
our $VERSION = "0.07";
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 );
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;
}
$day;
}
-sub Last
Sund
ay {
- my ($year, $month
) = (shift, shift)
;
+sub Last
D
ay {
+ 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 );
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;
}
$day;
}
diff --git
a/rt/share/html/Search/Calendar.html
b/rt/share/html/Search/Calendar.html
index
e711b86
..
e5a1c28
100644
(file)
--- a/
rt/share/html/Search/Calendar.html
+++ b/
rt/share/html/Search/Calendar.html
@@
-46,7
+46,7
@@
$NewQuery => 0
<thead>
<tr>
<th></th>
<thead>
<tr>
<th></th>
-% for (
1 .. 6, 0
) {
+% for (
@{$week{$weekstart}}
) {
<th width="14%"><%$rtdate->GetWeekday($_)%></th>
% }
</tr>
<th width="14%"><%$rtdate->GetWeekday($_)%></th>
% }
</tr>
@@
-54,7
+54,7
@@
$NewQuery => 0
<tbody>
<tr>
% while ($date <= $end) {
<tbody>
<tr>
% while ($date <= $end) {
-% if ( $date->day_of_week ==
1
) {
+% if ( $date->day_of_week ==
$startday_of_week
) {
<th><% $date->week_number %></th>
% }
<td class="<% $date->month != ($Month + 1) ? 'oddline' : '' %>"
<th><% $date->week_number %></th>
% }
<td class="<% $date->month != ($Month + 1) ? 'oddline' : '' %>"
@@
-66,7
+66,7
@@
$NewQuery => 0
% }
</td>
% $date = $set->next($date);
% }
</td>
% $date = $set->next($date);
-% if ( $date->day_of_week ==
1
) {
+% if ( $date->day_of_week ==
$startday_of_week
) {
</tr><tr>
% }
% }
</tr><tr>
% }
% }
@@
-125,7
+125,7
@@
$NewQuery => 0
</html>
<%INIT>
</html>
<%INIT>
-use RTx::Calendar;
+use RTx::Calendar
qw(FirstDay LastDay)
;
my $title = loc("Calendar");
my $title = loc("Calendar");
@@
-133,9
+133,18
@@
my @DateTypes = qw/Created Starts Started Due LastUpdated Resolved/;
my $rtdate = RT::Date->new($session{'CurrentUser'});
my $rtdate = RT::Date->new($session{'CurrentUser'});
+my $weekstart = 'Sunday'; #RT::SiteConfig? user pref?
+my %week = (
+ 'Saturday' => [6,0..5],
+ 'Sunday' => [0..6],
+ 'Monday' => [1..6,0],
+);
+my $startday_of_week = ${$week{$weekstart}}[0] || 7;
+my $endday_of_week = ${$week{$weekstart}}[-1] || 7;
+
my $today = DateTime->today;
my $today = DateTime->today;
-my $date
= RTx::Calendar::FirstMonday($Year, $Month + 1
);
-my $end
= RTx::Calendar::LastSunday($Year, $Month + 1
);
+my $date
= FirstDay($Year, $Month + 1, $startday_of_week
);
+my $end
= LastDay ($Year, $Month + 1, $endday_of_week
);
# use this to loop over days until $end
my $set = DateTime::Set->from_recurrence(
# use this to loop over days until $end
my $set = DateTime::Set->from_recurrence(