aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2019-10-14 14:03:44 +0100
committerGitHub <noreply@github.com>2019-10-14 14:03:44 +0100
commit7b11ef3880efcd2bc3fd66b336417480576f18f1 (patch)
tree378fd205ef30c9a7b3f7c845e5eda7701191974e
parente9abe342a60a3cea74efd6de31ffcc5bb0384a69 (diff)
parent6f4986e8dae2b936fbb9349ef15f907d30ffecb8 (diff)
downloadperlweeklychallenge-club-7b11ef3880efcd2bc3fd66b336417480576f18f1.tar.gz
perlweeklychallenge-club-7b11ef3880efcd2bc3fd66b336417480576f18f1.tar.bz2
perlweeklychallenge-club-7b11ef3880efcd2bc3fd66b336417480576f18f1.zip
Merge pull request #771 from oWnOIzRi/week030t1
add solution for week 30 task 1
-rw-r--r--challenge-030/steven-wilson/perl5/ch-1.pl33
1 files changed, 33 insertions, 0 deletions
diff --git a/challenge-030/steven-wilson/perl5/ch-1.pl b/challenge-030/steven-wilson/perl5/ch-1.pl
new file mode 100644
index 0000000000..82d8dc37dc
--- /dev/null
+++ b/challenge-030/steven-wilson/perl5/ch-1.pl
@@ -0,0 +1,33 @@
+#!/usr/bin/env perl
+# Author: Steven Wilson
+# Date: 2019-10-14
+# Week: 030
+
+# Task #1
+# Write a script to list dates for Sunday Christmas between 2019 and
+# 2100. For example, 25 Dec 2022 is Sunday.
+
+use strict;
+use warnings;
+use feature qw/ say /;
+use DateTime;
+
+my $start_year = 2019;
+my $end_year = 2100;
+my $sunday = 7;
+my $dt = DateTime->new(
+ year => $start_year,
+ month => 12,
+ day => 25
+);
+my @sunday_christmas;
+
+while ( $dt->year() <= $end_year ) {
+ if ( $dt->dow() == $sunday ) {
+ push @sunday_christmas, $dt->clone();
+ }
+ $dt->add( years => 1 );
+}
+
+say "List of Sunday Christmases between $start_year and $end_year:";
+say join "\n", @sunday_christmas;