diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2022-07-28 01:40:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-28 01:40:12 +0100 |
| commit | ed4ffafed4f2692ef1e100781ce95085b3b9e1e4 (patch) | |
| tree | cd2c2e2745bc81340e757bea98787ce850df789b /challenge-175 | |
| parent | d2a093191440c0932086eac5f42db7541ccbd6d7 (diff) | |
| parent | 47eb0093a4c9fc544fb127d4446bd95ce4f04653 (diff) | |
| download | perlweeklychallenge-club-ed4ffafed4f2692ef1e100781ce95085b3b9e1e4.tar.gz perlweeklychallenge-club-ed4ffafed4f2692ef1e100781ce95085b3b9e1e4.tar.bz2 perlweeklychallenge-club-ed4ffafed4f2692ef1e100781ce95085b3b9e1e4.zip | |
Merge pull request #6513 from jacoby/master
jacoby 175 pt 1
Diffstat (limited to 'challenge-175')
| -rw-r--r-- | challenge-175/dave-jacoby/perl/ch-1.pl | 28 |
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; +} |
