use v5.36; #use Feature::Compat::Class 0.07; use Object::Pad 0.78 qw(:experimental(custom_field_attr)); package Object::Groupware::Calendar 0.01; class Object::Groupware::Calendar : isa(Object::Groupware); use utf8; use Log::Any qw( ); use Data::ICal::DateTime; use Encode qw(decode_utf8); 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 ) } $log->tracef( "Object %s contents:\n%s", __CLASS__, decode_utf8 $data->as_string ); } # 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->end ? $a->end->compare( $b->end ) : 0 || $a->summary cmp $b->summary } $data->events( $set || (), $period || () ); return @events; } 1;