in reply to How Many Days in the Past?
Note that this doesn't require any additional modules other than Time::Local which you apparently already have installed and are using.#!/usr/bin/perl -w use strict; use Time::Local; use constant MAX_AGE => 20; sub _convert_date { # This takes a date in YYMMDD format and converts it to epoch # seconds (assumes 12:00:00 midnight) my $date = shift; my ( $year, $month, $day ) = ( $date =~ /(\d\d)(\d\d)(\d\d)/ ); $year += 2000; $month--; timelocal( 0,0,0,$day,$month,$year ); } sub older_than_MAX_AGE { my $date=shift; time-(MAX_AGE*86400) > $date; } print older_than_MAX_AGE(_convert_date("010401")),"\n"; print older_than_MAX_AGE(_convert_date("010411")),"\n";
|
|---|