date maths

Discussion in 'Perl Misc' started by mannu.arora@gmail.com, May 28, 2006.

  1. Guest

    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
    , May 28, 2006
    #1
    1. Advertising

  2. BZ Guest

    wrote in comp.lang.perl.misc:
    > 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.

    --
    BZ
    BZ, May 28, 2006
    #2
    1. Advertising

  3. <> wrote:

    > 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;


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, May 28, 2006
    #3
  4. wrote:

    > 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,

    --
    Bart
    Bart Van der Donck, May 28, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,244
    Michael Borgwardt
    May 30, 2004
  2. Ross Clement (Email address invalid - do not use)

    Maths expression drawing library

    Ross Clement (Email address invalid - do not use), Jan 11, 2006, in forum: Java
    Replies:
    4
    Views:
    601
    Vyacheslav Levitsky
    Oct 2, 2006
  3. Calum Maciver

    Maths Involved

    Calum Maciver, Feb 18, 2006, in forum: Java
    Replies:
    5
    Views:
    456
    Luke Webber
    Feb 19, 2006
  4. Andrew Bullock

    bit of a maths quesiton

    Andrew Bullock, Feb 5, 2005, in forum: C++
    Replies:
    2
    Views:
    308
    Victor Bazarov
    Feb 5, 2005
  5. Geoff

    Maths in HTML

    Geoff, Jan 4, 2007, in forum: HTML
    Replies:
    10
    Views:
    712
    Adrienne Boswell
    Jan 6, 2007
Loading...

Share This Page