ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: mazeckenrode on January 02, 2021, 01:19:57 AM

Title: Writing invalid dates
Post by: mazeckenrode on January 02, 2021, 01:19:57 AM
I've been using the following command successfully for months now, with the resulting date value visible in Directory Opus via tooltip or metadata panel:

ExifTool "-EXIF:DateTimeOriginal<filename" "-XMP:DateTimeOriginal<filename" "-IPTC:DateCreated<${filename;m/^(\d{4})[-_;\., ]*(\d{2})[-_;\., ]*(\d{2})/;$_=$1.$2.$3}" "-IPTC:TimeCreated<${filename;m/^\d{4}[-_;\., ]*\d{2}[-_;\., ]*\d{2}[-_;\., ]*(\d{2})[-_;\., ]*(\d{2})[-_;\., ]*(\d{2})/;$_=$1.$2.$3}" .

A few days ago, I inadvertantly* used the same command on a set of image files in whose names I represented the date December 1952 (no specific day number) as 1952-12-00. Full example filename: "1952-12-00 01;41;00 - Farm Journal - 101.jpg".

(* Meaning I completely overlooked the fact that I was running the command on filenames with presumably invalid date representations.)

After banging my head against the wall for a while, trying to figure out why Directory Opus wouldn't display the date tags I'd just set, I posted in the Directory Opus help forum (https://resource.dopus.com/t/setting-date-taken-in-exiftool-so-it-shows-in-opus/37493), where another user kindly pointed out that ExifTool had apparently written the invalid date representation without any complaint, and not surprisingly, Directory Opus declined to display the tags as written.

I've read the ExifTool FAQ entry on date and time formats (https://exiftool.org/faq.html#Q5), and did some searching in the forums, but haven't been able to locate any reference to date/time tags getting successfully written with a value of 0 for the day number. Is ExifTool supposed to do this, and not even give a warning about it? I could see it being potentially useful in certain circumstances, such as the 0-as-day-number getting ignored in an operation that sets XMP:DateTimeOriginal to year and month and possibly time value. (Is there any actual way to do that now?) Or, I could see making it so that any value of 0 encountered for the day number would be automatically bumped to 1 when writing any of the applicable date/time tags. Or at least give a warning.
Title: Re: Writing invalid dates
Post by: Phil Harvey on January 02, 2021, 01:15:19 PM
You're right.  ExifTool doesn't complain about a zero day or month.  I'll add a check for this and issue a warning and avoid writing date/time values like this.  Thanks for the suggestion.

- Phil