package DateTime::Event::CamPMSocial; =head1 NAME DateTime::Event::CamPMSocial - Find out when the next cam.pm social is =head1 SUMMARY use DateTime::Event::CamPMSocial; my $next_meeting = DateTime::Event::CamPMSocial->next_meeting(); The Cambridge UK Perl Mongers meet on a monthly basis. The day of the next meeting is the next working day of the week in the next month, e.g. the next meeting after Tuesday 3rd March 2009 will be Wednesday 1st April. The starting point was the Tuesday, 3rd March 2009 meeting. =cut use strict; use warnings; use DateTime; use Date::Calendar::Profiles qw( $Profiles ); use Date::Calendar; sub next_meeting { my $meet = DateTime->new( year => 2009, month => 3, day => 3 ); my $dow = $meet->dow(); my $cal = Date::Calendar->new( $Profiles->{'GB'} ); $meet->set_day(1); # start at the start of the month my $now = DateTime->now(); while ( DateTime->compare( $meet , $now ) < 0 ) { $meet->add( months => 1 ); while ( $meet->dow() > 5 || $dow > $meet->dow || $cal->is_full($meet->year,$meet->month,$meet->day) ) { $meet->add( days => 1 ); } } return $meet; } 1;