aggregator.pm: add month filter for events

This commit is contained in:
Milan
2022-10-23 21:59:02 +02:00
parent 74658b1c47
commit 38724c6e70

View File

@@ -8,6 +8,7 @@ use events();
use comments();
use calendar();
use project();
use Date::Calc;
#use base 'Exporter';
our @EXPORT_OK = qw(get_cache configure_cache put_cache get_list check_params);
@@ -172,6 +173,19 @@ sub check_params($$) {
$params->{date} = $date;
}
if (defined $params->{month}){
if ($params->{month} eq 'this') {
my ($y, $m) = split /-/, time::time_to_date();
$params->{from_date} = time::datetime_to_date("$y-$m-01");
$params->{till_date} = time::datetime_to_date("$y-$m-".Date::Calc::Days_in_Month($y,$m));
} elsif (my ($y, $m) = $params->{month} =~ m/^(\d\d\d\d)-(\d\d)$/) {
if ($m) {
$params->{from_date} = time::datetime_to_date("$y-$m-01");
$params->{till_date} = time::datetime_to_date("$y-$m-".Date::Calc::Days_in_Month($y,$m));
}
}
}
my $from_date = time::check_date( $params->{from_date} );
my $till_date = time::check_date( $params->{till_date} );