PerlAlien / File-Listing

Module to parse directoy listings
1 stars 3 forks source link

File::Listing::dosftp->list cannot handle MM-DD-YYYY date formats [rt.cpan.org #105446] #3

Closed plicease closed 1 year ago

plicease commented 4 years ago

https://rt.cpan.org/Ticket/Display.html?id=105446

File::Listing::dosftp->list cannot handle DIR listings that show the date
as MM-DD-YYYY.

Examples:

Can be handled:

06-23-15  10:12AM       <DIR>          IN

Cannot be handled:

06-23-2015  10:12AM       <DIR>          IN

The fix would be in this chunk:

  if (($date, $size_or_dir, $name) =
        /^(\d\d-\d\d-\d\d\s+\d\d:\d\d\wM)         # Date and time info
         \s+                                      # Some space
         (<\w{3}>|\d+)                            # Dir or Size
         \s+                                      # Some more space
         (.+)$                                    # File name
        /x )

The above might instead be:

  if (($date, $size_or_dir, $name) =
        /^(\d\d-\d\d-\d{2,4}s+\d\d:\d\d\wM)         # Date and time info
         \s+                                      # Some space
         (<\w{3}>|\d+)                            # Dir or Size
         \s+                                      # Some more space
         (.+)$                                    # File name
        /x )

Consider also supporting YYYY-MM-DD.

Regards,

Jo Monterosso
Grant Street Group
plicease commented 4 years ago

PR with tests are welcome.