NAME
Date::Find - find year, month, day from (filename) strings
SYNOPSIS
use 5.020;
my $info = guess_ymd('statement_20221201.pdf');
say "$info->{value} - $info->{year} - $info->{month} - $info->{day}";
# statement_20221201.pdf - 2022 - 12 - 01
my @dates = guess_ymd(['statement_20221201.pdf',
'statement_02.12.2022.pdf',
'random.pdf',
], components => 'ym');
for my $info (@dates) {
say "$info->{value} - $info->{year} - $info->{month} - $info->{day}";
}
# statement_20221201.pdf - 2022 - 12 - 00
# statement_02.12.2022.pdf - 2022 - 12 - 00
my @dates = guess_ymd(['statement_20221201.pdf',
'statement_02.12.2022.pdf',
'random.pdf',
], components => 'ym', mode => 'strict');
for my $info (@dates) {
say "$info->{value} - $info->{year} - $info->{month} - $info->{day}";
}
# statement_20221201.pdf - 2022 - 12 - 00
# statement_02.12.2022.pdf - 2022 - 12 - 00
find_ymd
SEE ALSO
Date::Extract - extract dates from more arbitrary text
Filename::Timestamp - extract date and time from filenames, with timezone