Skip to content

Instantly share code, notes, and snippets.

@bduggan
Created August 26, 2016 17:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bduggan/940a3d1c85bb3938b888ea795f6aa4ef to your computer and use it in GitHub Desktop.
Save bduggan/940a3d1c85bb3938b888ea795f6aa4ef to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl6
my @dates = Date.today, Date.today.succ ... ∞;
my %taken =
# first wednesday
plug-central => { $_.day-of-week == 3 and $_.weekday-of-month == 1 },
# second tuesday
plug-north => { $_.day-of-week == 2 and $_.weekday-of-month == 2 },
# third monday
plug-west => { $_.day-of-week == 1 and $_.weekday-of-month == 3 },
# second thursday
philly-pug => { $_.day-of-week == 4 and $_.weekday-of-month == 2 },
# third tuesday
philly-devops => { $_.day-of-week == 2 and $_.weekday-of-month == 3 },
# last tuesday
software-as-craft => { $_.day-of-week == 2 and $_.later(:1week).month != $_.month },
;
my @available = lazy gather {
for @dates -> $d {
next if %taken.values.grep({ $_($d) });
take $d;
}
};
my @proposed-philly-perlmongers =
@available.grep: { $_.day-of-week == 1 and $_.weekday-of-month == 2 }
.say for @proposed-philly-perlmongers[^10];
# output:
#
# 2016-09-12
# 2016-10-10
# 2016-11-14
# 2016-12-12
# 2017-01-09
# 2017-02-13
# 2017-03-13
# 2017-04-10
# 2017-05-08
# 2017-06-12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment