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

Date_GetPrev "error"

Thread Next
From:
Tony Esposito
Date:
April 15, 2010 10:59
Subject:
Date_GetPrev "error"
Message ID:
573224.86441.qm@web29003.mail.ird.yahoo.com
Hello,

Date_GetPrev only getting 3 previous days, not 5 previous days.  Using Perl 5.8.x.

Code
----

use strict;
use Date::Manip;
my @days = ( 'Fri', 'Mon', 'Tue', 'Wed', 'Thu' );
Date_Init("TZ=CST6CDT");
foreach (@days) {
  print $_ . "\n";
}
my @dates = ();
my $today = ParseDate('today');
foreach (@days) {
  push(@dates, substr(Date_GetPrev($today, $_, 0/1/2),0,8));
}
foreach (@dates) {
  pop(@dates);
  print $_ . "\n";
}
exit;

Output
------
Fri
Mon
Tue
Wed
Thu
20100409
20100412
20100413


      
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