blob: 72267824b00b9887e150fe5f138e191c9b5a63d4 (
plain)
- use v5.36;
- use Feature::Compat::Class 0.07;
- package Object::Groupware::Calendar 0.01;
- class Object::Groupware::Calendar;
- 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 @events = map { Object::Groupware::Event->new( entry => $_ ) } sort {
- $a->start->compare( $b->start )
- || $a->start->compare( $b->start )
- || $a->summary cmp $b->summary
- } $data->events( $set || (), $period || () );
- return @events;
- }
- 1;
|