%z returns +0000 instead of nothing when timezone is unknown

Started by GordonFreemanK, January 20, 2022, 01:40:52 PM

Previous topic - Next topic

GordonFreemanK

If I am to believe the strftime documentation, if I have a non-offset-aware date/time stored for instance in the EXIF or XMP sections, I'd expect %z to not output anything in date formats.
In fact, the default format works that way:

user@computer:~$exiftool ~/Pictures/My-picture.jpg -EXIF:CreateDate -s -s -s
2022:01:19 15:16:17
user@computer:~$exiftool ~/Pictures/My-picture.jpg -EXIF:CreateDate -s -s -s -d '%Y-%m-%d %H:%M:%S%z'
2022-01-19 15:16:17+0000
user@computer:~$exiftool ~/Pictures/My-picture.jpg -XMP:CreateDate -s -s -s
2022:01:19 15:16:17+0300
user@computer:~$exiftool ~/Pictures/My-picture.jpg -XMP:CreateDate -s -s -s -d '%Y-%m-%d %H:%M:%S%z'
2022-01-19 15:16:17+0300
user@computer:~$exiftool ~/Pictures/My-picture.jpg '-XMP:CreateDate=2022:01:19 15:16:17'
    1 image files updated
user@computer:~$exiftool ~/Pictures/My-picture.jpg -XMP:CreateDate -s -s -s
2022:01:19 15:16:17
user@computer:~$exiftool ~/Pictures/My-picture.jpg -XMP:CreateDate -s -s -s -d '%Y-%m-%d %H:%M:%S%z'
2022-01-19 15:16:17+0000


I'd expect that second and last commands to have returned a string without timezone information.

I tried version 12.38 in both Windows 10 and Ubuntu 21.10 with the same results.

Is this by design?

Phil Harvey

Sorry for the delay in responding, but this question required a bit of research on my part because I had forgotten how this was done.

It turns out this is intentional.  See Note number 2 here.

- 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 ($).

Phil Harvey

I was playing around with this and can't figure out how you got ExifTool to return a default-formatted timezone without a colon.  I get this:

> exiftool a.jpg -xmp:createdate -s -s -s
2022:01:19 15:16:17+03:00


However, %z does return a time zone without a colon.  I don't really like this inconsistency.  Also, I see how it may be inconvenient that %z returns a time zone when the date/time didn't contain one.

I'm not sure of the best way to resolve these issues, or even whether they are important enough to spend more time on.

- 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 ($).

GordonFreemanK

Quote from: Phil Harvey on February 08, 2022, 08:52:24 AM
I was playing around with this and can't figure out how you got ExifTool to return a default-formatted timezone without a colon.  I get this:

> exiftool a.jpg -xmp:createdate -s -s -s
2022:01:19 15:16:17+03:00


It's been a while sorry, but I think this might have been a copy/paste mistake by me when creating the post. I get a colon when I run the command now, both on my Windows and Linux machines.


Quote from: Phil Harvey on February 08, 2022, 08:52:24 AM
However, %z does return a time zone without a colon.  I don't really like this inconsistency.  Also, I see how it may be inconvenient that %z returns a time zone when the date/time didn't contain one.
I'm not sure of the best way to resolve these issues, or even whether they are important enough to spend more time on.

- Phil

Don't worry thanks for looking into it! I worked around the issue in the end