Forum Moderators: coopster & phranque

Message Too Old, No Replies

Month Day Year in CGI Script

         

Insiderman

10:24 pm on Jul 12, 2006 (gmt 0)

10+ Year Member



I am using a PERL calendar script. One of the links on the HTML pages created from the script looks like this:

http://www.example.com/cgi/suite/calendar/calendar.cgi?
request=display_specific_date_events&website=default&
month=7&day=12&year=2006&category_id=&set=1&session=44b573710dd85cf4

The problem is that I want to link to a current calendar page without updating this portion of the URL above: &month=7&day=12&year=2006

I've contacted the vendor who provided this rather useless reply:

"I am not aware of any specific link that you could use that would automatically display events for the current day, but you could achieve the same thing by using a script to automatically update the above link each day. Specifically, you could use a Perl or PHP script that would generate the numeric values for today's month, day of month, and year and then fill them into the URL that you listed above so that it would always point to the events for the current day. Obviously, the most important part of that URL is the following:

&month=7&day=12&year=2006

The new script would need to fill in and replace the "7" after "&month=", the "12" after "&day=", and the "2006" after "&year=" with the correct values for those items each day. I hope this helps."

Obviously, the vendor did not help... especially since I am not the hot PERL programmer some of you are.

Any suggestions on how I might fix this to AUTOMATICALLY bring in the correct month, day, year? Thanks!

[edited by: coopster at 1:41 pm (utc) on July 13, 2006]
[edit reason]
[1][edit reason] generalized domain; fixed sidescroll [/edit]
[/edit][/1]

perl_diver

5:31 am on Jul 13, 2006 (gmt 0)

10+ Year Member



you could use localtime():

[perldoc.perl.org...]

to get the day/month/year data you need then stuff that into the URI string as needed.

lexipixel

8:20 am on Jul 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




Something like this will do it;

#
($d,$m,$y) = (localtime)[3,4,5];
$y = ($y + 1900);
#

NOTE: you need to check to see if your script is using "one based" or "zero based" month values, (ie- does January equal "1" or "0", does December equal "11" or "12"?).

Make adjustment to $m is needed (ie- add or subtract "1" to $m)...

Insiderman

3:10 pm on Jul 15, 2006 (gmt 0)

10+ Year Member



Thanks. I was able to identify in the PERL script where they are making the calculations for date based on your descriptions:
$m = $as{'month'};
$d = $as{'day'};
$y = $as{'year'};
When I try these variable names in the cgi call, however, I'm not getting anything useful. Here's how I'm putting them into the call:
http://www.example.com/cgi/suite/calendar/calendar.cgi?request=display_specific_date_events&website=default&month=$m&day=$d&year=$y&set=1
Thanks!

[edited by: jatar_k at 4:19 pm (utc) on July 15, 2006]
[edit reason]
[1][edit reason] examplified [/edit]
[/edit][/1]

lexipixel

7:05 pm on Jul 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




The URL in an earlier post indicates the use of a session ID... It may not work without it.

ie-

http://www.example.com/cgi/suite/calendar/calendar.cgi?
request=display_specific_date_events&website=default&
month=7&day=12&year=2006&category_id=&set=1&session=44b573710dd85cf4