The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Image::EXIF::DateTime::Parser - parser for EXIF date/time strings

SYNOPSIS

  use Image::EXIF::DateTime::Parser;

  my $parser = Image::EXIF::DateTime::Parser->new;
  printf "%d\n", $p->parse("2009:05:05 09:17:37");

    produces "1241540257", if you are in America/Los_Angeles timezone.

DESCRIPTION

While parsing standards-compliant EXIF Date/Time string is easy, allowing for the various ways different non-standards-compliant implementations mangle these strings is neither easy nor pleasant. This module encapsulates this complexity for you. It provides a parser which takes an EXIF Date/Time string and returns time in "calendar time" format, aka. time_t.

EXPORTS

Nothing.

METHODS

$p = Image::EXIF::DateTime::Parser->new

Returns a new parser object.

Introduced in version 1.1.

$time_t = $p->parse( '2009:05:05 09:17:37' )

Takes a single argument: an EXIF Date/Time string, and returns a time_t value by interpreting the string as local time.

Returns undef when the string represents an unknown date/time (zeros or blanks).

Throws an exception if the string is not parseable.

Introduced in version 1.1.

SECURITY

The module untaints the input string and passes the numbers (and spaces in some cases) as arguments to POSIX::mktime. Thus as long as mktime can deal with numbers and/or spaces on its input, the worst that can happen is that an invalid date/time string will produce a surprising calendar time value or an undef.

CAVEATS

Non-canonical time strings

Because it uses POSIX::mktime, this module can accept theoretically invalid field values (such as 32nd day of month) and canonicalize them by appropriately changing other field values.

Timezones

The parser currently ignores the timezone information and treats the string as date/time in the timezone it currently runs in. Please note that the EXIF standard actually forbids including timezone information the Date/Time string.

Invalid formats

This module tries to understand some common non-standards-compliant EXIF Date/Time strings, but naturally it is not possible to allow for all present and future ways that implementations can choose to mangle them. If you encounter a string that is not recognized, but could be, please report it and I will try to add it in the next version.

AUTHOR

Marcin Owsiany <marcin@owsiany.pl>

SEE ALSO

Image::Info(3), Image::ExifTool(3)

LICENSE

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 87:

You forgot a '=back' before '=head1'