Dates with Perl

F

Firewalker

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

Joe Smith

Firewalker said:
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).
 
J

Jürgen Exner

Firewalker said:
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
 
D

dink

Firewalker said:
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
 
L

lesley_b_linux

Firewalker said:
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
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top