Output all dates in UTC?

Started by geoffblack, November 15, 2017, 12:46:41 PM

Previous topic - Next topic

geoffblack

One final question on timezone output: If you have a date without timezone information, like the IFD0:ModifyDate, and set a date format like "%Y-%m-%d %H:%M:%S%z" with the TZ env var set to "UTC", ExifTool will always add "+0000".

Example raw data: "2014:05:12 15:16:33"; ExifTool XML output:
<IFD0:ModifyDate>2014-05-12 15:16:33+0000</IFD0:ModifyDate>

Using the default date format, ExifTool outputs the datetime without a timezone:
<IFD0:ModifyDate>2014:05:12 15:16:33</IFD0:ModifyDate>.

I understand the reasoning for this, but is the default date format the only way to get timezone-naive output on dates that don't have timezone information?

Phil Harvey

I don't think I understand the question.  Note that there are 3 different types of date/time values.  You are talking about number 2 with IFD0:ModifyDate:

1. A date/time complete with time zone (eg. most XMP date/times)

--> ExifTool shows the complete date/time with time zone

2. A relative date/time with no time zone (eg. EXIF date/time tags)

--> ExifTool shows the date/time without a time zone

3. An absolute date/time with no time zone (eg. System date/time tags, or some QuickTime date/time tags when QuickTimeUTC is set)

--> ExifTool shows the date/time in the local system time zone

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

geoffblack

Right, so in the case of #2, if I set a date format string that includes "%z", ExifTool will output "+0000" at the end of that datetime (with environment var TZ set to "UTC") even though there is no timezone information. I'm asking if that is a bug or as intended.

Hayo Baan

Looks like intentional to me; you ask for the timezone with the %z specification :)
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

geoffblack

Quote from: Hayo Baan on November 29, 2017, 02:09:26 AM
Looks like intentional to me; you ask for the timezone with the %z specification :)

Ha! Yes, yes. Shame strftime doesn't have a conditional %z.

Phil Harvey

You could try something like this maybe to filter the default date/time formats:

exiftool -api filter="s/^(\d{4}):(\d{2}):(\d{2}) /$1-$2-$3 /" ...

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

geoffblack

Quote from: Phil Harvey on November 29, 2017, 11:09:20 AM
You could try something like this maybe to filter the default date/time formats:
exiftool -api filter="s/^(\d{4}):(\d{2}):(\d{2}) /$1-$2-$3 /" ...

Yeah, I'll take care of it in post-processing. It's actually nice to be able to maintain the timezone naivety, so I'll deal with the default format. Thanks, again.