Vienna.pm Meeting dates for 2017 (as calculated by Perl 6)

By the power vested in me by the laziness of the other Vienna.pm members, I hereby declare the following dates for Vienna.pm TechSocialMeetings:

  • Mon, 2017-01-16 @ validad
  • Tue, 2017-02-21
  • Wed, 2017-03-22
  • Thu, 2017-04-20
  • Fri, 2017-05-19
  • Mon, 2017-06-19
  • Tue, 2017-09-19
  • Wed, 2017-10-18
  • Thu, 2017-11-16
  • Fri, 2017-12-22

Each meeting will start at 19:00, unless we decide for some other time (check the mailinglist and #Austria.pm on irc.perl.org). The location will also be announced a few days prior to the meeting. I encourage all companies using Perl in Vienna to consider hosting the meeting at least once a year.

Meetings will feature some talks, followed by a social part in a nearby pub / restaurant. If you do want to hear me rambling about my latest hacks, please consider presenting some of your latest hacks. If nothing you do seems worth a short talk at a TechMeet, I strongly suggest you start looking for a more interesting job!

The Algorithm

Some years ago we learned that a fixed weekday prevents some people from attending, because the already have some other commitment on this day. So we move the meeting around, having it on a different weekday each month. We start with Monday, and loop through the days. As we skip the meetings in July and August (summer holidays), we end up with 10 months, which map nicely onto the five weekdays.

I choose the third weekday of each month after a quick scan of my calendar seemed to indicate that the third-ish week contains the least holidays. Also, I already have an event on Mon, 2017-01-09 (which is the second Monday in January)!

The Code

Here's a Perl 6 implementation:

 #!/usr/bin/env perl6

my @weekdays = < Mon Tue Wed Thu Fri >;

sub MAIN ( Int $year ){
    for (1 .. 10) -> $meeting {
	my $month = $meeting < 7 ?? $meeting !! $meeting + 2;

	my $month_start = Date.new(year => $year, month => $month, day=>1);
	my $first_dow=$month_start.day-of-week;
        my $want_dow = $meeting % 5 || 5 ;
	$want_dow += 7 if $want_dow <= $first_dow;
	my $day = 14 + 1 + $want_dow - $first_dow;

	my $meeting_date = Date.new(year=>$year, month=>$month, day=>$day);
        say "@weekdays[$meeting_date.day-of-week - 1], $meeting_date";
    }
}

A quick walk-through

@weekdays is an array of weekday names (because I was too lazy to install DateTime::Format).

I use sub MAIN and it's parameter list to get the year from the command line.

Then I iterate through the 10 planned meetings. I calculate the month based on the meeting number, adding 2 to the month if we're after june (thereby skipping july and august).

The next 5 lines use some simple (and probably stupid) module math to get the correct date of the 3rd weekday I'm looking for in this month: $first_dow is the day-of-week-number of the first day of a given month. $want_dow is the day-of-week I want this meeting to happen on. If the modulus returns 0, I set it to 5 (which is the result of some trial-and-error, not of my mathematical genius). If $want_dow is smaller or equal than $first_dow, I add 7, to make the modular calculation easier (again, I assume a real mathematician has a better solution for this..). Finally I add the modular difference between $first_dow and $want_dow to 14 (because I want to skip two weeks), to get the date I'm looking for.

Now I only have to generate a Date and print out the result.

If you want to improve and / or golf my code, you can do so in the comment section below, or on your own blog / twitter etc - I'd love to see the results!

Oh, and it seems I already have something to talk about at out first meeting on Monday, 16th Jan 2017, in the Validad office!