Skip to content

Instantly share code, notes, and snippets.

@tadzik
Created April 16, 2020 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tadzik/ca52a6ef8d125dd9b28a5245b92ed913 to your computer and use it in GitHub Desktop.
Save tadzik/ca52a6ef8d125dd9b28a5245b92ed913 to your computer and use it in GitHub Desktop.
use 5.020;
use strict;
use warnings;
use DateTime;
my $date = DateTime->now;
my $month = $date->month;
my $days_left = 0;
while ($date->month == $month) {
if ($date->day_of_week < 6) {
$days_left++;
}
$date->add(days => 1);
}
say "$days_left workdays left in month (including today)";
my $date = Date.today;
my $month = $date.month;
my $days_left = 0;
while ($date.month == $month) {
if ($date.day-of-week < 6) {
$days_left++;
}
$date = $date.later(:1day);
}
say "$days_left workdays left in month (including today)";
> time perl remaining.pl
11 workdays left in month (including today)
perl remaining.pl 0,10s user 0,02s system 99% cpu 0,121 total
> time raku remaining.raku
11 workdays left in month (including today)
raku remaining.raku 0,20s user 0,04s system 135% cpu 0,174 total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment