dépôts
/
ikiwiki
/
events.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0fe4f59
)
fix date day focus
author
Julien Moutinho
<julm+ikiwiki+events@autogeree.net>
Wed, 30 Apr 2014 16:45:01 +0000
(18:45 +0200)
committer
Julien Moutinho
<julm+ikiwiki+events@autogeree.net>
Wed, 30 Apr 2014 17:55:16 +0000
(19:55 +0200)
events.pm
patch
|
blob
|
history
diff --git
a/events.pm
b/events.pm
index
2820c60
..
6cc233c
100644
(file)
--- a/
events.pm
+++ b/
events.pm
@@
-519,22
+519,35
@@
sub preprocess (@) {
: gettext('Agenda');
}
: gettext('Agenda');
}
- my %focus_set;
- if (defined $params{day} and $params{day} =~ m/^(\d+)$/) {
- my ($day) = ($1);
- $focus_set{day} = $day;
+ my %focus_set =
+ ( day => $params{focus}->day()
+ , month => $params{focus}->month()
+ , year => $params{focus}->year()
+ );
+ if (defined $params{year} and $params{year} =~ m/^(\d+)$/) {
+ my ($year) = ($1);
+ $focus_set{year} = $year;
}
}
- if (defined $params{month} and $params{month} =~ m/^(\d+)$/) {
+ if (defined $params{month} and $params{month} =~ m/^(\d+)$/
and ($params{type} eq 'month' or $params{type} eq 'day')
) {
my ($month) = ($1);
$focus_set{month} = $month;
}
my ($month) = ($1);
$focus_set{month} = $month;
}
- if (defined $params{year} and $params{year} =~ m/^(\d+)$/) {
- my ($year) = ($1);
- $focus_set{year} = $year;
+ if (defined $params{day} and $params{day} =~ m/^(\d+)$/ and $params{type} eq 'day') {
+ my ($day) = ($1);
+ $focus_set{day} = $day;
+ }
+ if (not defined $focus_set{day}) {
+ $focus_set{day} = 1;
+ }
+ else {
+ my $month = DateTime->new(year => $focus_set{year}, month => $focus_set{month}, day => 1);
+ my $last_day_of_month = $month->add(months => 1)->subtract(days => 1)->day();
+ $focus_set{day} = $last_day_of_month
+ if $focus_set{day} > $last_day_of_month;
}
$params{focus}->set(%focus_set);
}
$params{focus}->set(%focus_set);
- if (defined $params{day} and $params{day} =~ m/^([+-])(\d+)$/) {
+ if (defined $params{day} and $params{day} =~ m/^([+-])(\d+)$/
and $params{type} eq 'day'
) {
my ($sign, $days) = ($1, $2);
my $duration = DateTime::Duration->new(days => $days, end_of_month => 'limit');
$params{focus}
my ($sign, $days) = ($1, $2);
my $duration = DateTime::Duration->new(days => $days, end_of_month => 'limit');
$params{focus}
@@
-542,7
+555,7
@@
sub preprocess (@) {
? $params{focus}->add_duration($duration)
: $params{focus}->subtract_duration($duration);
}
? $params{focus}->add_duration($duration)
: $params{focus}->subtract_duration($duration);
}
- if (defined $params{month} and $params{month} =~ m/^([+-])(\d+)$/) {
+ if (defined $params{month} and $params{month} =~ m/^([+-])(\d+)$/
and ($params{type} eq 'month' or $params{type} eq 'day')
) {
my ($sign, $months) = ($1, $2);
my $duration = DateTime::Duration->new(months => $months, end_of_month => 'limit');
$params{focus}
my ($sign, $months) = ($1, $2);
my $duration = DateTime::Duration->new(months => $months, end_of_month => 'limit');
$params{focus}