sub SLAtest
#check if we are in SLA service hours
{
#declare variables
my $serviceday='0';
my $servicehour='0';
my $slatime='0';

#get time into @now array from localtime function
my @now = localtime time;       #@now gets date/time

# @now[6] is number of day of week
if ((@now[6] <'1') or (@now[6] >'5'))
{
$serviceday = '0';
}
else
{
$serviceday = '1';
}

# @now[2] is hour of day next check if time is past 17:30 or past 18:00
if ((@now[2] <'9') or ((@now[2]=='17') and (@now[1]>'29')) or (@now[2]>='18'))
{
$servicehour = '0';
}
else
{
$servicehour = '1';
}

#if all conditions are true, we are in SLA hours, else sla = false, don't care!
if ($servicehour == '1' and $serviceday == '1')
{
$slatime='1';
}
else
{
$slatime='0';
}
#print "SLA contract=$slatime \n";
return $slatime, $serviceday, $servicehour ;
}


MAIN:
#Are we in SLA hours?
@sla = &SLAtest
# ($slastatus, $serviceday, $servicehour);

if (@sla[0] == '1')
{
$validsla = "In SLA Time";
}
else
{
$validsla = "Out of SLA Time";
}

exit(0);
