Acme-PM-Berlin-Meetings

 view release on metacpan or  search on metacpan

lib/Acme/PM/Berlin/Meetings.pm  view on Meta::CPAN

    }
    if ($last_wed_of_month->month == 12) {
	return _get_dec_meeting($last_wed_of_month);
    }
    $last_wed_of_month;    
}

sub _get_last_wed_of_month {
    my $dt_berlin = shift;
    my $last_day_of_month = DateTime->last_day_of_month(year => $dt_berlin->year, month => $dt_berlin->month, time_zone => 'Europe/Berlin');
    my $dow = $last_day_of_month->day_of_week;
    my $last_wed_of_month = $last_day_of_month->add(days => $dow < 3 ? -$dow-4 : -$dow+3);
    _adjust_hour($last_wed_of_month);
    $last_wed_of_month;
}

sub _get_dec_meeting {
    my $dt = shift;
    $dt = $dt->clone;
    if ($dt->month == 12) {
	$dt->add(months => 1); # end_of_month does not matter
    }
    $dt->set(day => 3);
    my $dow = $dt->day_of_week;
    $dt->add(days => $dow < 4 ? -$dow+3 : -$dow+10);
    _adjust_hour($dt);
    $dt;
}

sub _adjust_hour {
    my $dt = shift;
    if ($dt->year >= 2024 || ($dt->year == 2023 && $dt->month >= 5)) {
	$dt->set(hour => 18);
    } elsif ($dt->year >= 2016) {
	$dt->set(hour => 19);
    } else {
	$dt->set(hour => 20);
    }
}

1;

__END__

=head1 NAME

Acme::PM::Berlin::Meetings - get the next date of the Berlin PM meeting

=head1 SYNOPSIS

    use Acme::PM::Berlin::Meetings;
    next_meeting(1)

Or use the bundled script:

    berlin-pm

=head1 NOTES

This module knows about special Berlin.PM traditions like postponing
the December meeting to the first or second week in January.

=head1 AUTHOR

Slaven Rezic

=head1 SEE ALSO

L<Acme::PM::Barcelona::Meeting>, L<Acme::PM::Paris::Meetings>.

=cut



( run in 0.804 second using v1.01-cache-2.11-cpan-800906f7e73 )