Handling of time zone in capure date

galbit

Joined: 2005-11-07
Posts: 18
Posted: Mon, 2005-11-07 11:16

I would like to urge that either the specification of a time zone be dropped from the capture date display in gallery (blindly reproducing whatever is in the Exif header) or that the UTC offset for the Exif header can be specified when adding photos.

Something is fundamentally wrong now: the capture date/time in the Exif header is in an unspecified time zone. The header simply lacks the information so there's no way to translate that date/time to one with an explicit time zone (as gallery attempts to do). Assumptions will fail: while most people use 'local time', they will keep adjusting to local time when taking their camers abroad (think holidays). Professionals and those who travel a lot probably set their cams to UTC. It also is far from sure that either gallery server or viewer will be in the same time zone as the camera when the picture was taken.

If you can tell gallery the time zone your Exif headers live in, it will truly know the dates/times and can display them meaningfully. But then it should still be possible to leave the offset unspecified (because sometimes you really don't know).

When the first picture of my new-born son showed a capture time 58 minutes before his birth (I remember that time very well) I finally decided to search the galley forums for the solution. Actually, I was surprised to find no mention of this problem at all. Or am I missing something? The problem seems real enough.

For the record:
Gallery version: 1.5-debian1
Apache version: Apache/2.0.54
PHP version: 4.3.10-16
Operating system: Debian/linux 2.6.11.9

 
Tim_j
Tim_j's picture

Joined: 2002-08-15
Posts: 6818
Posted: Mon, 2005-11-07 13:11

Hello,

Currently Gallery does not handle time zones at all.
It just displays dates/times.

If i understand you correct, you would like to give a timezone for each photo, right ?

Jens
--
Last Gallery v1 developer and translation manager.

 
galbit

Joined: 2005-11-07
Posts: 18
Posted: Mon, 2005-11-07 13:50

Hi,

I don't know whether gallery itself *handles* time zones, but it surely displays them. It probably leaves time zone handling to time zone libraries, I would guess.

So the actual problem might be in reading the Exif header. Maybe that date/time value is somehow interpreted as referring to the current locale and then stored as a standard Unix time_t (or what's it called; I'm not a programmer) which implicitly refers it to UTC (GMT). My guess is that this 'conversion' only gives the desired results when the current locale (for the environment where the Exif header is read) is indeed the same as was used on the camera, which is far from guaranteed. So, let the user specify the locale (or UTC offset) to use, or ackknowledge that the time zone it is unspecified and display the Exif data uninterpreted (makes use of Unix time_t or equivalent impossible).

Makes sense?

Bart
--
Just a user ;-)

 
Tim_j
Tim_j's picture

Joined: 2002-08-15
Posts: 6818
Posted: Mon, 2005-11-07 14:20

Hello Bart,

i am now more confused then before.

Gallery just shows the value. Nothing more. or like you say "uninterpreted" (i also dont know a better or "correct" word.)
So regardless on which server, in which timezone with which locale .. 12am on 07 of November is showed as 12am on 07 of November :)

But when i understood you correct, you would like to see something like this:

- enter a default timezone in which gallery is, this timezone is used for every anonymous user
- optionally user can set his/her timezone
- add possibility to enter an offset to each picture
- show dates according the offset and used timezone

?

Jens
--
Last Gallery v1 developer and translation manager.

 
galbit

Joined: 2005-11-07
Posts: 18
Posted: Mon, 2005-11-07 17:46

Oh! I can see where I have you confused. Let me be more specific: there is no problem in rendering the Exif header data (the popup that you get through the "photo properties" option), but in the custom "Capture Date" field which gallery can show below your pictures.

If I enable the Capture Date custom field, Gallery gives me "Capture Date : Wed 02 Mar 2005 03:42:06 CET" below my son's photograph, while the Exif header has just "2005-03-02 03:42:06" and nothing more. So somewhere along the line an assumption is made that I had set my camera to CET when the picture was taken, which is not true. I had my camera on UTC, my son was born at 04:40 CET (03:40 UTC), and all his pictures (except the ultrasounds) were taken after that!

The easy fix is to make sure Gallery displays just the Exif data in the Capture Date custom field without any mention of a time zone. A more elaborate fancy solution could be to provide a mechanism to specify the Exif time zone, ultimately on a per picture basis, but a default would be handy.

Thanks for paying attention!

 
galbit

Joined: 2005-11-07
Posts: 18
Posted: Tue, 2005-11-08 09:48

Hi Jens,

I can be even more specific: after peering into the code for a bit, I think that the getItemCaptureDate function (in util.php) is at the root of this. It uses the strtotime function to parse the textual representation from the Exif header into a Unix timestamp. But strtotime needs to assume a time zone to do that. This is not explicitly handled, so strtotime will use whatever is set for the server. That works only if camera and server use the same time zone (not necessarily likely under heavy travel and if your server is in a remote place as well).

For outputting the value, strftime is used. This function also needs to assume a time zone to convert the Unix time stamp to something humanly readable, and it also uses whatever is set for the server. If that hasn't changed since importing the picture, the numerical values (hours, minutes, etc.) will actually come out the same, but strftime adds a string that identifies the assumed time zone (e.g. "CET"), which can easily lead to a wrong interpretation of the numbers.

It still boils down to: either handle the time zone explicitly when parsing Exif data into Unix datetime values, or simply reproduce the string in the Exif header without refering to a time zone.
The latter would probably mean that you can't use a Unix timestamp since there is no proper way to store a value with an unspecified time zone in it.

Would this also be an issue in v2?

regards,
Bart

 
Harold Dupain

Joined: 2006-01-26
Posts: 9
Posted: Thu, 2006-01-26 10:30

Hi Galbit,

Thnx this post about comprehensive
guide is helping a lot to understand the understanding
issue.

Quote: Would this also be an issue in v2?
Same question here.

Harold,

 
galbit

Joined: 2005-11-07
Posts: 18
Posted: Wed, 2006-05-17 12:51

My server admin has recently upgraded to gallery 2 and so far the same issue seems to be present there. Times in the Exif header are still interpreted using the server's time zone setting. I will take it to the relevant gallery2 forum.