CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
A prog that works out a date

 



siceman105
Deleted

Aug 31, 2000, 2:40 AM

Post #1 of 2 (2068 views)
A prog that works out a date Can't Post

Hi, I need a program that calculate a series of dates. Let me explain.

If the user enters 1st July, and the program knows that 15 days later there should be an event, and then ten days after that there should be another event, it would print out

1st July: Initial Date
15th July: First Event
25th July: Second Event

and that kinda thing, it would also need to take into consideration the fact that some months have 31,30 and 28 days.

Please help!!

Thanks

Sice


Kanji
User / Moderator

Aug 31, 2000, 4:23 PM

Post #2 of 2 (2068 views)
Re: A prog that works out a date [In reply to] Can't Post

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

#!/usr/bin/perl -wl

use strict;
use Date::Manip qw( DateCalc ParseDate UnixDate );

my %days = ( 0 => "Initial", 14 => "First",
24 => "Second", 34 => "Third" );

my $date = ParseDate( $ARGV[0] )
|| die "You didn't supply a (valid) date";

foreach my $offset ( sort { $a <=> $b } keys %days ) {
print UnixDate( DateCalc( $date, "+ $offset days" ), "%b %d" ),
": $days{$offset}";
}
__END__
Jul 01: Initial
Jul 15: First
Jul 25: Second
Aug 04: Third</pre><HR></BLOCKQUOTE>

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives