Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Help

by marius (Hermit)
on Dec 06, 2000 at 21:44 UTC ( [id://45249]=note: print w/replies, xml ) Need Help??


in reply to how do I issue e-mail using perl? (was:Help)

Another thing to find out would be how your putting the date into the data file. That's something we would need to know to figure out the "prior date" portion.

I can't come up with a quick non-CPAN way to do that to cover Dec 31 -> Jan 1 changes, and also lastday(month)->firstday(nextmonth) changes.

Any folks have any ideas on how to parse the date, assuming they're stored as MM/DD/YYYY (if they're separated fields, they can be join()'d, and if DD/MM/YYYY or some other format, it should be easily changable to MM/DD/YYYY)? Dates are probably one of the most irritating things when it comes to programming. =]

-marius

Replies are listed 'Best First'.
(jeffa) Re: Re: Help
by jeffa (Bishop) on Dec 06, 2000 at 22:06 UTC
    I think this will do the trick:
    use strict; use Time::Local; my $time = timelocal(localtime); $time -= (60 * 60 * 24); # subtract one day my ($s, $min, $h, $d, $mon, $y, $w, $yd, $isdst) = localtime($time); printf("Yesterday's date: %02d:%02d:%02d-%04d/%02d/%02d\n", $h, $min, $s, $y+1900, $mon+1, $d);
    The trick is to work in Epoch seconds, and let localtime figure out what the date is.

    Jeff

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    F--F--F--F--F--F--F--F--
    (the triplet paradiddle)
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://45249]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-26 00:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found