#!/usr/bin/perl
use strict;
use warnings;
use Date::Calc qw( Day_of_Week Delta_Days
Nth_Weekday_of_Month_Year
Date_to_Text_Long English_Ordinal
Day_of_Week_to_Text Month_to_Text Today Week_Number);
my ($year,$month,$day) = Today();
my $dow = Day_of_Week($year,$month,$day);
my $n = int( Delta_Days(
Nth_Weekday_of_Month_Year($year,$month,$dow,1),
$year,$month,$day)
/ 7) + 1;
printf("%s is the %s %s in %s %d.\n",
Date_to_Text_Long($year,$month,$day),
English_Ordinal($n),
Day_of_Week_to_Text($dow),
Month_to_Text($month),
$year);
printf("Just FYI the week number is %d in %d.\n",
Week_Number($year, $month, $day),
$year);
__END__
$ perl test.pl
Thursday, October 12th 2017 is the 2nd Thursday in October 2017.
Just FYI the week number is 41 in 2017.
####
my $n = int( Delta_Days(
Nth_Weekday_of_Month_Year($year, $month, $dow, 1),
$year, $month, $day)
/ 7) + 1;
say "Number: " . $n;
__END__
Number: 2
##
##
#!/usr/bin/perl
use strict;
use warnings;
use feature 'say';
use Date::Calc qw( Today Day_of_Week );
my ($year,$month,$day) = Today();
my $week = int(($day + Day_of_Week($year,$month,1) - 2) / 7) + 1;
say "Week number: " . $week;
__END__
$ perl test.pl
Week number: 3