aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-175/dave-jacoby/perl/ch-1.pl28
1 files changed, 28 insertions, 0 deletions
diff --git a/challenge-175/dave-jacoby/perl/ch-1.pl b/challenge-175/dave-jacoby/perl/ch-1.pl
new file mode 100644
index 0000000000..33ade5d6fe
--- /dev/null
+++ b/challenge-175/dave-jacoby/perl/ch-1.pl
@@ -0,0 +1,28 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use experimental qw{ say postderef signatures state };
+
+use DateTime;
+
+my $year = 2022;
+
+for my $month ( 1 .. 12 ) {
+ my $dt = DateTime->new(
+ year => $year,
+ month => $month,
+ day => 1,
+ time_zone => 'floating'
+ );
+ $dt->add( days => 32 );
+
+ # Remember that days of week are 1-7, and 0 doesn't match
+ # this isn't crontab
+ while (1) {
+ $dt->subtract( days => 1 );
+ next unless $dt->month == $month;
+ last if $dt->day_of_week == 7;
+ }
+ say $dt->ymd;
+}