aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Jacoby <jacoby.david@gmail.com>2022-07-27 19:10:33 -0400
committerDave Jacoby <jacoby.david@gmail.com>2022-07-27 19:10:33 -0400
commit47eb0093a4c9fc544fb127d4446bd95ce4f04653 (patch)
treec25710f23130a5c974713734802d673964fd85bd
parent440fd5bfe27fdfff4e787bcd8e3b01a51200b266 (diff)
downloadperlweeklychallenge-club-47eb0093a4c9fc544fb127d4446bd95ce4f04653.tar.gz
perlweeklychallenge-club-47eb0093a4c9fc544fb127d4446bd95ce4f04653.tar.bz2
perlweeklychallenge-club-47eb0093a4c9fc544fb127d4446bd95ce4f04653.zip
jacoby 175 pt 1
-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;
+}