Continues from previous week.
Feel free to submit a merge request or open a ticket if you found any issues with this post. We highly appreciate and welcome your feedback.
Additional feedback to the our Perl Weekly Challenge’s Twitter account is much appreciated.
CPAN modules used:
This is a similar task to the previous challenges. Thus, we observed some participants reuse the same code with some modifications.
For a start, look at the solution by Ryan Thompson and Colin Crain which were heavily commented. This should provides us with some context and their thought on solving this tasks. Similarly but in blog post, read the write-up by Laurent Rosenfeld, E. Choroba, and Arne Sommer. They provides us with even more insight on how they approached this task.
And as usual, a few things that caught our attention.
Date::Manip::Recur CPAN module used by Colin Crain was rather interesting and unique compare to typical CPAN modules found in most submitted solutions. The CPAN module provides a way to parse and manipulate recurrence which was used by the participant to filter out all weekdays.
my $recur = new Date::Manip::Recur; $recur->parse("0:0:0:1*0:0:0*IBD","Jan 1 2019","Jan 1 2019","Dec 31 2019"); my @date = $recur->dates();
Now, if the above recurrence modifier string was rather obscure, look at the solution by Javier Luque which use the
DateTime::Event::Recurrence CPAN module. As shown below, the code is pretty much self-explanatory.
my $working_days = DateTime::Event::Recurrence->weekly( days => [1 .. 5] );
For a purist solution (without using any CPAN modules), Adam Russell was the only particpant who seemed to achieve that feat.
CPAN modules used:
This task reminded us of the optional third task we used to have in previous challenges in using web services or APIs.
For this task, we can group the submitted solutions into three groups. Those who scrapped the daylight gain and loss data from the Interweb, those who scrapped and pre-cached, or those who calculate dynamically.
Again, certain solutions that caught our attentions.
The forward-looking statement or safe habour statement found in the submission by Colin Crain was rather intriguing and justifiable due to the uncertainties in predicting the daylight result.
Ryan Thompson basically wrote a console app or rather a CPAN module to calculate the difference of daylight between two months.
(1) Weekdays and Daytimes by Adam Russell
(2) Weekdays, Daylight and Raku by Arne Sommer
(3) Sunrise and Sunset in Perl by Dave Jacoby
(4) Perl Weekly Challenge 037: Weekdays and Daylight Gain/Loss by E. Choroba
(5) Perl Weekly Challenge - 037 by Javier Luque
(6) Perl Weekly Challenge 37: Week Days in Each Month and Daylight Gain/loss by Laurent Rosenfeld
(7) Perl Weekly Challenge 37: weekdays and day lengths by Roger Bell_West