blob: 386a749f0c91e16b13435ca59bdbeb6eede19ec5 (
plain)
- use v5.36;
- use Feature::Compat::Class 0.07;
- package Object::Groupware::Calendar 0.01;
- class Object::Groupware::Calendar : isa(Object::Groupware);
- use utf8;
- use Log::Any qw( );
- use Data::ICal::DateTime;
- use Object::Groupware::Event;
- field $log = Log::Any->get_logger;
- # borrow from Data::ICal::new() signature
- field $data : param = undef;
- field $filename : param = undef;
- ADJUST {
- if ($data) {
- if ( $data isa Data::ICal ) { }
- else { $data = Data::ICal->new( data => $data ) }
- }
- elsif ($filename) { $data = Data::ICal->new( filename => $filename ) }
- if ( $log->is_trace ) {
- use DDP;
- p $data;
- }
- }
- # mimick Data::ICal::DateTime::events() signature
- method events ( $set = undef, $period = undef )
- {
- $log->infof(
- 'will pick events between %s and %s',
- $set->start, $set->end
- ) if $set;
- my $dt_locale = $self->dt_locale;
- my $dt_time_zone = $self->dt_time_zone;
- my @events = map {
- Object::Groupware::Event->new(
- entry => $_,
- dt_locale => $dt_locale,
- dt_time_zone => $dt_time_zone,
- )
- } sort {
- $a->start->compare( $b->start )
- || $a->start->compare( $b->start )
- || $a->summary cmp $b->summary
- } $data->events( $set || (), $period || () );
- return @events;
- }
- 1;
|