Andreas Schmidt writes:
> s.th. like this (not finished but may give you an idea ...):
...one possible (but long) method deleted...
> script was tested on sh.hpbin and on HP-UX and on AIX for today ...
>
> not covered: leap years.
>
> Will become very longish ... very boxed ("verschachtelt" in German ...) but
> primitive ....
How to do this in perl:
-----CUT HERE-----
#!/bin/perl
use Date::DateCalc(calc_new_date);
# Get today's date.
($sec,$min,$hour,$day,$month,$year,$wday,$yday,$isdst) = localtime(time);
# Compute 5 days into the future.
($newyear,$newmonth,$newday) = calc_new_date($year,$month+1,$day,+5);
printf "Five days into the future: %d/%d/%d\n",$newmonth,$newday,$newyear;
-----CUT HERE-----
Notes:
1) DateCalc is an optional add-on freeware module available from your nearest
CPAN archive. See www.perl.com for details. I don't include DateCalc in the
Perl/iX binary distribution -- you'll need to build it yourself.
2) localtime() returns $month as 0..11, but calc_new_date() expects 1..12,
thus we do $month+1.
Perhaps this example will give you an idea of why I consider Perl to be the
most powerful thing I've ever ported to MPE. :-)
The Perl/iX home page: http://www.cccd.edu/~markb/perlix.html
The Perl home page: http://www.perl.com
--
Mark Bixby E-mail: [log in to unmask]
Coast Community College Dist. Web: http://www.cccd.edu/~markb/
District Information Services 1370 Adams Ave, Costa Mesa, CA, USA 92626-5429
Technical Support Voice: +1 714 438-4647
"You can tune a file system, but you can't tune a fish." - tunefs(1M)
|