Good Question, it's an undocumented feature that I've simply observed others using from time to time.
However, testing it shows that it works across month boundaries, but fails on year boundaries
use POSIX qw(strftime);
use strict;
use warnings;
my @date = localtime;
while (<DATA>) {
my ($year, $mon, $day, $expected) = split;
@date[3,4,5] = ($day, $mon, $year);
my $fmt = strftime "%Y%m%d", @date;
print "$fmt <=> $expected " . ($fmt eq $expected ? 'matched' : 'fa
+iled') . "\n";
}
=prints
20110501 <=> 20110501 matched
20110430 <=> 20110430 matched
20110429 <=> 20110429 matched
20110102 <=> 20110102 matched
20110101 <=> 20110101 matched
20110512 <=> 20101231 failed
20110512 <=> 20101230 failed
=cut
__DATA__
111 4 1 20110501
111 4 0 20110430
111 4 -1 20110429
111 0 2 20110102
111 0 1 20110101
111 0 0 20101231
111 0 -1 20101230
Truth is, using DateTime is cleaner anyway, so will update my script.
|