The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#------------------------------------------------------------------------------
# File:         time_zone.config
#
# Description:  ExifTool config file to return time zone from an image
#
# Notes:        The Composite:TimeZone tag defined here attempts to determine
#               the time zone for an image.  If possible, the time zone for
#               DateTimeOriginal is returned, but if this can't be determined
#               then the time zone for CreateDate and then ModifyDate are used.
#
# Usage:        exiftool -config time_zone.config -timezone FILE
#
# Requires:     Any version of ExifTool
#
# Revisions:    2016/10/03 - P. Harvey Created
#------------------------------------------------------------------------------

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        FileName => {
            Desire => {
                0 => 'DateTimeOriginal',
                1 => 'CreateDate',
                2 => 'ModifyDate',
                3 => 'GPSDateStamp',
                4 => 'GPSTimeStamp',
                5 => 'OffsetTimeOriginal',  # (DateTimeOriginal)
                6 => 'OffsetTimeDigitized', # (CreateDate)
                7 => 'OffsetTime',          # (ModifyDate)
                8 => 'TimeZoneOffset',      # (ModifyDate)
            },
            RawConv => q{
                return $val[5] if $val[5];
                return $val[6] if $val[6];
                return $val[7] if $val[7];
                if (defined $val[8]) {
                    my $tzh = $val[8];
                    $tzh =~ s/ .*//;
                    return TimeZoneString($tzh * 60);
                }
                if (defined $val[3] and defined $val[4]) {
                    my $loc = $val[0] || $val[1] || $val[2];
                    print "$loc\n";#TEST
                    if ($loc) {
                        my @loc = split /[: ]/, $loc;
                        my @gmt = split /[: ]/, "$val[3] $val[4]";
                        return TimeZoneString(GetTimeZone([@loc[5,4,3,2]], [@gmt[5,4,3,2]]));
                    }
                }
                return undef;
            },
        },
    },
);

1;  #end