date maths

M

mannu.arora

Hi

I m caught up in a different kind of problem.
I wish to create a shell/perl script which will accept the "from date"
and "to date".

But the problem is how to find the date next to "from date". I m able
to find the difference between the 2 dates using a shell script logic.

Even with localtime function of perl I can find the past or the future
date from the current date. But Can I use some similar function which
will take user specified date instead of the current date to calculate
the next date. Pls provide your inputs.

Thanks
Mannu
 
B

BZ

Even with localtime function of perl I can find the past or the future
date from the current date. But Can I use some similar function which
will take user specified date instead of the current date to calculate
the next date. Pls provide your inputs.

You're probably looking for Date::parse.
 
T

Tad McClellan

I m caught up in a different kind of problem.


Different from _what_?

I wish to create a shell/perl script which will accept the "from date"
and "to date".

But the problem is how to find the date next to "from date".


use Date::Calc;
 
B

Bart Van der Donck

I m caught up in a different kind of problem.
I wish to create a shell/perl script which will accept the "from date"
and "to date".

But the problem is how to find the date next to "from date". I m able
to find the difference between the 2 dates using a shell script logic.

Even with localtime function of perl I can find the past or the future
date from the current date. But Can I use some similar function which
will take user specified date instead of the current date to calculate
the next date. Pls provide your inputs.

There are pre-built and long-proven constructions for that kind of
things:

#!perl
use strict;
use warnings;
use Date::Calc qw(Add_Delta_Days);
my @fromdate = (2006, 5, 28);
my @next2fromtodate = Add_Delta_Days(@fromdate, +1);
print join '-', @next2fromtodate;

More info:
http://search.cpan.org/dist/Date-Calc/

Hope this helps,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top