Assuming I have the following in a .tpl:iw_iterate list='dcr.Alerts' var='alert'iw_if expr= '{iw_value name="alert.ExpireDate"/} < $Today 'I'm trying to compare the expiration date in my .dcr to today. Does anyone have a quick and slick way to do this? I could write a javascript function and get the date?Part II - Attempting the javascript routeiw_perl my $mydate = SCRIPT todayStr(); /SCRIPT/iw_perlh4 align="left" Date: {iw_value name='$mydate'/} /h4The value between the h4 tags is blank...Maybe I should post this in the perl section? (help)-Dave
OK, I tried going the perl route! I was wondering if I needed to include some declarations in the .tpl?Here's what I have come up with so far:iw_perl my $string1 = localtime(time); my $date1 = ParseDate($string1);/iw_perlThe $string1 variable is being populated however the compiler doesn't like the "ParseDate" statement. I'm also planning to use: my $flag = Date_Cmp($date1, $date2);Will I run into the same issue? I did use the command line compiler as the GUI really didn't give a descriptive error message: Could not process template..Thanks!-Dave
use Date::Manip;
BEGIN{ $ENV{TZ} = "US/Pacific"; };
#!/usr/bin/perluse Date::Manip;my $string1 = localtime(time);my $date1 = ParseDate($string1);my $flag1 = Date_Cmp($date1, "yesterday");my $flag2 = Date_Cmp($date1, "today");my $flag3 = Date_Cmp($date1, "tomorrow");print "S: $string1\nD: $date1\n($flag1, $flag2, $flag3)\n";
S: Fri Dec 8 18:26:32 2006 2006120818:26:32(1, 0, -1)
In an effort to bear my soul, I have hacked together a non-working solution to my dilemma. Continuing this thread, I'd like to call the perl from my .tpl - I have pasted the relavent stuff below for comments and critiques. The line that contains the iw_if continues to be the source of my issues. It seems I can not call the perl I have embedded in the page. Please feel free to point out my obvious mistake(s). -Dave[html] sub good_Date # If the passed date is less than or equal to today, its good! { # get passed date my ($date1) = shift (@_); # get today's date in YYYYMMDD my $string1 = localtime(time); my $date2 = ParseDate($string1); # Compare two dates - Date_Cmp will return 1,0,-1 if yesterday,today,tomorrow my $flag = Date_Cmp($date2, $date1); if ( $flag < 0 ) { # date2 is earlier return 0; } else { # date1 is equal or earlier return 1; } }[/html]
You are correct and I apologize for missing it! I have added it and now I get a syntax error in the line: <iw_if expr= ' good_Date( {iw_value name="alerts.ExpireDate"/} ); eq 1 ' > What I am trying to do is pass the value that I am reading from the DCR. What is the proper syntax? Do I need perl tags around the sub call?-Dave
<iw_if expr= ' good_Date( {iw_value name="alerts.ExpireDate"/} ); eq 1 ' >
use Date::Manip;use Time:arseDate;# get today's datemy $string1 = localtime(time);# format datemy $date1 = parsedate($string1);my $flag1 = Date_Cmp($date1, "tomorrow");
OK, now I'm digging in and being more efficient! :-)Modifying your prior example I have the following: use Date::Manip;use Time:arseDate;# get today's datemy $string1 = localtime(time);# format datemy $date1 = parsedate($string1);my $flag1 = Date_Cmp($date1, "tomorrow"); The problem line is the last, assigning $flag1 variable...a) Why doesn't it like tomorrow in my Windows environment?b) Do I have any tools available to me in Teamsite to diagnose this issue myself? After trying to re-gen the page, "Could not process template" really doesn't help me understand my issue. Thanks!-Dave
BEGIN{ $ENV{TZ} = "US/Eastern";};