Pinned topic Action Validation Hook on Date (PERL)
DonaldN 06000249ET287 Posts
Re: Action Validation Hook on Date (PERL)2013-05-29T03:08:57ZThis is the accepted answer. This is the accepted answer.
It is much easier to find a solution you treat it as a non-ClearQuest, as in, pure Perl, issue. Google will bring you many examples.
GoodGulf 120000501T610 Posts
Re: Action Validation Hook on Date (PERL)2013-05-29T19:44:42ZThis is the accepted answer. This is the accepted answer.
You are constrained by the modules provided with the version of per in ClearQuest.
The easiest way to do this is by converting everything to epoch seconds, then it's just straight math.
I forget what perl calls its validation routines so I'll call it date_val...
my ($result, $when);
my $now = time();
my $daysecs = 60 * 60 * 24;
# Assumes mm/dd/yyy hh:mm:ss
# my $DatePlanned = $entity->GetFieldStringValue("DatePlanned");
my $DatePlanned = "4/29/2013 00:00:00";
if ($DatePlanned =~ m#(\d+)/(\d+)/(\d+) (\d+):(\d+):(\d+)#)
$when = Time::Local::timelocal($6, $5, $4, $2, $1-1, $3);
$result = "Invalid date format";
if (int (($when - $now)/$daysecs) < 0)
$result = "DatePlanned: Insert a date next than today";