Perl Check for Business Days with DateTime module

by GarciaPL on Thursday 25 April 2013

Quick piece of code how to check if given date in DateTime module format is business day or not ;) I think that this function is very usefull for every kind of business application that you would like to write in the near future ;)

my @day_of_week = ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday');

sub check_business_day {
 my ($name_of_day) = @_;
 if ( grep( /^$name_of_day$/, @day_of_week ) ) {
  return 1;
 } else {
  return 0;
 }
}

check_business_day($date_time->day_name());

Function returns 1 if given day name from $date_time variable is a business day, otherwise it return 0.

Reference :
[1] Source Pastebin.com