Dates with Perl

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Firewalker

    Dates with Perl

    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.


  • Joe Smith

    #2
    Re: Dates with Perl

    Firewalker wrote:
    [color=blue]
    > Hey guys,[/color]

    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 ).

    Comment

    • Jürgen Exner

      #3
      Re: Dates with Perl

      Firewalker wrote:[color=blue]
      > 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 [...][/color]

      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


      Comment

      • dink

        #4
        Re: Dates with Perl

        "Firewalker " <hana1@rogers.c om> wrote in message
        news:fvadnVSU-KJbfcXcRVn-gw@rogers.com.. .[color=blue]
        > 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[/color]
        am

        that's easy:

        use Date::Calc qw(Add_Delta_Da ys);

        # 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_af ter = Add_Delta_Days( @l_date, +7);

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

        # print the stuff
        printf ("l_date=%04 d-%02d-%02d l_date_week_aft er=%04d-%02d-%02d
        l_date_week_bef ore=%04d-%02d-%02d\n", @l_date, @l_date_week_af ter,
        @l_date_week_be fore);

        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




        Comment

        • lesley_b_linux@yahoo.co.yuk

          #5
          Re: Dates with Perl

          "Firewalker " <hana1@rogers.c om> writes:
          [color=blue]
          > 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.[/color]

          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/pod...ost-questions-

          You might want to familiarise yourself with the posting guidelines for
          comp.lang.perl. misc at http://mail.augustmail.com/~tadmc/cl...uidelines.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

          Comment

          Working...