Are there other modules that would allow this? Here's a snippet of what I tried, but it didn't work:
When I pass "older_than_MAX_AGE" the date of 010329, I get the following data:use Time::Local; use constant MAX_AGE => 20; # Other code here sub older_than_MAX_AGE { my $date = _convert_date( $_[0] ); # convert yymmdd t +o epoch seconds my $max_epoch_seconds = MAX_AGE * 60 * 60 * 24; # MAX_AGE should b +e days. This converts it to seconds. my ( $day, $month, $year ) = (localtime)[3..5]; $year += 1900; my $today = timelocal( 0,0,0, $day, $month, $year ); my $cutoff_date = $today - $max_epoch_seconds; return $date < $cutoff_date ? 1 : 0 ; } sub _convert_date { # This takes a date in YYMMDD format and converts it to epoch seco +nds (assumes 12:00:00 midnight) my $date = shift; my ( $year, $month, $day ) = ( $date =~ /(\d\d)(\d\d)(\d\d)/ ); $year += 2000; timelocal( 0,0,0,$day,$month,$year ); }
| $cutoff_date | '986281200' |
| $date | '988527600' |
| $max_epoch_seconds | 1728000 |
| $_[0] | '010329' |
| $today | '988009200' |
As you can see, it says that the date that I am passing in is *newer* than today: 988527600 > 988009200, even though today is 010423 and the date passed in is 010329. Can anyone see what I'm doing wrong?
Thanks, J. Atzger
In reply to How Many Days in the Past? by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |