develooper Front page | perl.beginners | Postings from April 2002

Re: Backing up two days from localtime

Thread Previous | Thread Next
From:
Michael Lamertz
Date:
April 26, 2002 07:08
Subject:
Re: Backing up two days from localtime
Message ID:
20020426135032.GB8689@lamertz.net
On Fri, Apr 26, 2002 at 08:32:21AM -0400, Tara Calishain wrote:

> I'm anticipating coming across this same problem with user input dates, and
> I don't expect the seconds trick will work for that one.
> 
> For example, say a user specified $day-$month-$year and ten days, and I
> wanted to generate a date string for every day going back ten days.

Although Randal L. Schwartz posted a hillarious comment on Date::Manip

    (http://archive.develooper.com/beginners%40perl.org/msg22416.html)

you should take a look at that module.  I have used it quite a lot to
let people pass more or less generic time/date specifications to my
scripts.  It does for example things like that:

    ---------- snip ----------
    nijushiho:~# perl -MDate::Manip -le 'print UnixDate("44 days ago", "%Y%m%d")'
    20020313
    nijushiho:~# 
    ---------- snip ----------

It comes at a price though, so I wouldn't use it to process some 20 million
lines of webserver logs in a nightly run :-)

-- 
		       If we fail, we will lose the war.

Michael Lamertz                        |      +49 221 445420 / +49 171 6900 310
Nordstr. 49                            |                       mike@lamertz.net
50733 Cologne                          |                 http://www.lamertz.net
Germany                                |               http://www.perl-ronin.de 

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About