Dates with Perl

Discussion in 'Perl' started by Firewalker, Sep 28, 2004.

  1. Firewalker

    Firewalker Guest

    Hey guys,
    I am newbie to perl. I am trying to deal with dates ( such trying to find
    what the date would be after month). Is therea function or date class( I am
    a java programmer, I couldnt find the right word instead of class) to do the
    job?
    Thanks for any help.
     
    Firewalker, Sep 28, 2004
    #1
    1. Advertising

  2. Firewalker

    Joe Smith Guest

    Firewalker wrote:

    > Hey guys,


    Don't post separate messages to separate newsgroups.
    You're supposed to post a single message to multiple groups
    simultaneously. It's called cross-posting. Someone has
    already answered in the alt.perl newsgroup.

    Post to comp.lang.perl.misc instead of here (comp.lang.perl).
     
    Joe Smith, Sep 28, 2004
    #2
    1. Advertising

  3. Firewalker wrote:
    > I am newbie to perl. I am trying to deal with dates ( such trying to
    > find what the date would be after month). Is therea function or date
    > class [...]


    In spite your name you may want to put on your fireproof suit.

    What happened when you asked Google (this question is asked often), asked
    the FAQ (this question is asked often; although personally I find the FAQ
    answer somewhat lacking), or asked CPAN (there are many modules to deal with
    dates: http://search.cpan.org/search?query=date&mode=module)?

    If your question would have been which module to use: typically people
    recommend Date::Calc or Date::Manip the most.

    jue
     
    Jürgen Exner, Sep 28, 2004
    #3
  4. Firewalker

    dink Guest

    "Firewalker" <> wrote in message
    news:...
    > Hey guys,
    > I am newbie to perl. I am trying to deal with dates ( such trying to find
    > what the date would be after month). Is therea function or date class( I

    am

    that's easy:

    use Date::Calc qw(Add_Delta_Days);

    # get current date
    @l_date = sub {($_[5]+1900, $_[4]+1, $_[3])}->(localtime);

    # or set some other date
    @l_date = (2004, 5, 8);

    # add a week to @l_date
    @l_date_week_after = Add_Delta_Days(@l_date, +7);

    # subtract a week from @l_date
    @l_date_week_before = Add_Delta_Days(@l_date, -7);

    # print the stuff
    printf ("l_date=%04d-%02d-%02d l_date_week_after=%04d-%02d-%02d
    l_date_week_before=%04d-%02d-%02d\n", @l_date, @l_date_week_after,
    @l_date_week_before);

    but if you wannna know a date after a month you have to write a function
    which handles year/month rollovers and uses Add_Delta_Days accordingly

    --
    dink.
    Toyota MR2 Club Poland
    www.mr2.pl
     
    dink, Oct 1, 2004
    #4
  5. Firewalker

    Guest

    "Firewalker" <> writes:

    > Hey guys,
    > I am newbie to perl. I am trying to deal with dates ( such trying to find
    > what the date would be after month). Is therea function or date class( I am
    > a java programmer, I couldnt find the right word instead of class) to do the
    > job?
    > Thanks for any help.


    Welcome to comp.lang.perl

    This newsgroup, despite it's level of activity, has been declared defunct in
    Google
    and in http://www.perldoc.com/perl5.8.4/po...groups-on-Usenet---Where-do-I-post-questions-

    You might want to familiarise yourself with the posting guidelines for
    comp.lang.perl.misc at http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.text
    before posting there.

    I note from your headers that you are a Windows user or at least you used MS
    Outlook to post here. If you were using a Linux install of Perl then I would
    say use:

    man perl
    man perlfaq
    perldoc perldoc
    perldoc perl

    but I don't have a clue what documentation you'd get with Perl on Windows. (I
    have heard that ActiveState Perl has a help button somewhere on the Start
    button menu but can't verify this at all.)

    You might want to browse http://www.perl.org, http://www.perldoc.com/, http://www.perl.com
    and http://www.cpan.org for modules (the nearest Perl has to Java classes)

    Also put Perl into a google search then trawl through the webpages you find
    there and the group archives for answers to any questions you might have that
    might have been answered already.

    If you want to download modules from CPAN then check your perl documentation
    to see if 'perl -MCPAN -e shell' will work or look for something similar. It
    will do the installation work for you.

    HTH

    Lesley
     
    , Oct 21, 2004
    #5
    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. David Lozzi

    Dates dates dates dates... SQL and ASP.NET

    David Lozzi, Sep 29, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    882
    Rob Schieber
    Sep 30, 2005
  2. PW

    Dates! Dates! Dates!

    PW, Aug 7, 2004, in forum: ASP General
    Replies:
    4
    Views:
    209
    Mark Schupp
    Aug 9, 2004
  3. Replies:
    1
    Views:
    212
    Jano Svitok
    Jul 17, 2007
  4. kellygreer1

    RFC-822 dates into Ruby dates

    kellygreer1, Jun 8, 2008, in forum: Ruby
    Replies:
    1
    Views:
    213
    Eric I.
    Jun 8, 2008
  5. Dr J R Stockton

    FAQ Dates; Opera Dates.

    Dr J R Stockton, Jun 18, 2007, in forum: Javascript
    Replies:
    0
    Views:
    170
    Dr J R Stockton
    Jun 18, 2007
Loading...

Share This Page