Owen wrote:
> On Sun, 11 Feb 2007 03:18:00 -0500
> Mathew Snyder <[EMAIL PROTECTED]> wrote:
> 
>> Tom Phoenix wrote:
>>> On 2/9/07, Mathew <[EMAIL PROTECTED]> wrote:
>>>
>>>> I'm running this as a cron job 1 minute after midnight on Saturday
>>>> nights (Sunday morning) so as to cover all of Saturday back through the
>>>> previous Sunday.  Does your suggestion mean I'd have to run it late
>>>> Sunday night in order for it to cover Saturday back to the previous
>>>> Sunday (since the timestamp would be 24 hours ago)?
>>> The idea is to run it sometime in the first hour (or so) of the day on
>>> Sunday. (Lots of cron tasks get scheduled for that first minute of the
>>> day or week; it's probably more reliable to run it a few minutes
>>> later.) When it runs, it needs to determine the previous day's date
>>> (right?). It can do that by giving localtime an adjusted time value,
>>> instead of the current time.
>>>
>>>> I'm also guessing that this corrects the problem I mentioned regarding
>>>> skipping the 31st of Jan which was in the middle of the week.  Is that a
>>>> good assumption?
>>> Well, that problem came from your own date-handling code (yes?); if
>>> you use Perl's code (i.e., the localtime function), you shouldn't have
>>> those kinds of bugs. Unless I've misunderstood you.
>>>
>>> Good luck with it!
>>>
>>> --Tom Phoenix
>>> Stonehenge Perl Training
>>>
>> Sorry to rehash this but from this:
>>
>> #!/usr/bin/perl
>>
>> use warnings;
>> use strict;
>>
>> my @date     = (localtime (time - (24*60*60)))[3..5];
>>
>> foreach my $i (@date) {
>>         print $i . "\n";
>> }
>>
>> exit;
>>
>> I get this:
>>
>> 10
>> 1
>> 107
>>
>>
>> I still have to add 1 to the month.  Is that right?  Also, the year still 
>> needs
>> to be fixed by adding 1900 but from what I've read that is due to the way
>> computers work and not necessarily because of Perl.
> 
> 
> 
> Yes, most computer programs count from 0, so the months
> Jan Feb Mar  are 0 1 2, therefore you need to add 1 to it to get the 
> conceptual value of the month, 1 2 3
> 
> 
> As for the year, that's just the way it is, you got to add 1900 to the number 
> that is generated from the expression. 
> 
> So to get yesterdays date, probably make it "more understandable", write
> 
> my ($day, $month, $year) = (localtime (time - 86400))[3..5];
> 
> $month = $month + 1;
> 
> $year  = $year + 1900;
> 
> print "$day $month $year\n";
> 
> 
> 
> HTH
> 
> 
> Owen
>

any way you could take a look at my initial post and help me figure out what
might be screwy with Feb?

Mathew

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to