Bug 452677 - The date is passed to iNaturalist in the wrong format
Summary: The date is passed to iNaturalist in the wrong format
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-WebService-iNaturalist (show other bugs)
Version: 7.7.0
Platform: Microsoft Windows Microsoft Windows
: NOR normal (vote)
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-16 14:18 UTC by Steve Franks
Modified: 2022-04-23 11:04 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 7.7.0


Attachments
attachment-20768-0.html (1.78 KB, text/html)
2022-04-16 17:48 UTC, Steve Franks
Details
Metadata and GPX (123.27 KB, application/zip)
2022-04-18 11:33 UTC, Steve Franks
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Franks 2022-04-16 14:18:06 UTC
SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***
INaturalist reports missing date, because the date field is incorrectly formatted. Digikam provides date and time, iNaturalist only wants date.

STEPS TO REPRODUCE
1.  Select images
2. Choose iNaturalist from the export menu.
3.  Examine thee try that has been created on iNaturalist website 

OBSERVED RESULT
INaturalist reports ‘missing date’, but when the entry is edited the date observed field contains the correct date.

EXPECTED RESULT
Date is accepted by iNaturalist 

SOFTWARE/OS VERSIONS
Windows:  11
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Steve Franks 2022-04-16 14:28:55 UTC
INaturalist receives:-
2022-04-14T08:56:52 GMT Summer Time
Expects:-
2022-04-14
Comment 2 joergmlpts 2022-04-16 16:49:06 UTC
Thank you for your report.

I have followed your steps to reproduce the issue. I have uploaded 3 images that I took yesterday and created an iNaturalist observation. This is the result: https://www.inaturalist.org/observations/111590956 "Missing date" is not reported and under "Observed:" the date, time, and my timezone are correctly shown. The date and time shown on the iNat website exactly matches the date and time of the first photo in DigiKam.

My guess is that your timezone "GMT Summer Time" is not accepted by iNaturalist. The export plugin obtains it with QDateTime.timeZoneAbbreviation() from the first observation photo. That looks like an awfully long name for a timezone abbreviation and it is imaginable that the iNat API doesn't parse and process it correctly. Would you mind trying other names for your timezone?

Gilles certainly knows class QDateTime better than me.  Maybe he has a suggestion for an improvement. We definitely do not want to send only the date.
Comment 3 caulier.gilles 2022-04-16 16:59:13 UTC
Hi,

I don't know if QDateTime as extra capabilities with time zone (perhaps in Qt6).

Any way, in digiKam core, we have used QLocale method to make special time transformations.

https://doc.qt.io/qt-5/qlocale.html#dateFormat

Else, of course, take a look to QTimeZone :

https://doc.qt.io/qt-5/qtimezone.html

Gilles
Comment 4 Steve Franks 2022-04-16 17:48:17 UTC
Created attachment 148191 [details]
attachment-20768-0.html

How do I change the timezone in digikam?
Steve

On Sat, 16 Apr 2022 at 17:59, <bugzilla_noreply@kde.org> wrote:

> https://bugs.kde.org/show_bug.cgi?id=452677
>
> caulier.gilles@gmail.com changed:
>
>            What    |Removed                     |Added
>
> ----------------------------------------------------------------------------
>          Resolution|DOWNSTREAM                  |---
>              Status|NEEDSINFO                   |REOPENED
>      Ever confirmed|0                           |1
>
> --- Comment #3 from caulier.gilles@gmail.com ---
> Hi,
>
> I don't know if QDateTime as extra capabilities with time zone (perhaps in
> Qt6).
>
> Any way, in digiKam core, we have used QLocale method to make special time
> transformations.
>
> https://doc.qt.io/qt-5/qlocale.html#dateFormat
>
> Else, of course, take a look to QTimeZone :
>
> https://doc.qt.io/qt-5/qtimezone.html
>
> Gilles
>
> --
> You are receiving this mail because:
> You reported the bug.
Comment 5 joergmlpts 2022-04-16 18:06:19 UTC
Steve asks a good question. We are dealing with the timezone of a picture, not the system timezone.

Gilles, is there an editor in DigiKam where one can edit the date and time and timezone of a picture?

Where does the timezone of a picture come from? Will a picture that I took in February have a different timezone than a picture that I took yesterday? If would think so. So the timezone of a picture is constructed when DigiKam loads metadata of a picture? If so, DigiKam gives the picture timezone "GMT SUmmer Time".
Comment 6 Maik Qualmann 2022-04-16 18:49:09 UTC
The date of an image, if available, comes from the image metadata, usually OriginalTime. DigiKam ignores the time zone. On the one hand, the cause is that cameras have not previously saved the time zone in the image metadata. Newer cameras use a fairly new metadata tag to store the time zone.
But if I see it correctly in the code, only the date is transmitted if there are no other places in the code.

https://invent.kde.org/graphics/digikam/-/blob/master/core/dplugins/generic/webservices/inaturalist/inattalker.cpp#L1286

Maik
Comment 7 joergmlpts 2022-04-16 20:56:41 UTC
Thanks, Maik!

The actual code is https://invent.kde.org/graphics/digikam/-/blob/master/core/dplugins/generic/webservices/inaturalist/inatwindow.cpp#L803 where the observation date and time is sent as "observed_on_string" to iNaturalist. This string is constructed in lines 799 to 801 where for Steve "GMT Summer Time" gets appended to the ISO date and time representation.
Comment 8 joergmlpts 2022-04-17 03:06:45 UTC
Hi Steve,
  it seems the daylight savings time variant of GMT is called BST. Can you change your timezone to BST? That will be system-wide change of your computer's timezone not just a setting in DigiKam, if I understand correctly. You may need to reboot after that change. In DigiKam maybe under "Album" better click "Reread Metadata from Files" before you upload photos to iNaturalist again.

I came across BST here: https://stackoverflow.com/questions/16086962/how-to-get-a-time-zone-from-a-location-using-latitude-and-longitude-coordinates
That's info on querying the timezone based on date/time as well as latitude and longitude. That functionality would allow all photos with latitude/longitude in their metadata get correct timezones assigned. Maybe that's something to consider for Gilles and Maik.

Joerg
Comment 9 Maik Qualmann 2022-04-17 05:23:34 UTC
The QDateTime::toString(Qt::ISODate) function already appends a time zone extension if it exists. In the code, however, a time zone is appended again, that should be the problem.

Maik
Comment 10 joergmlpts 2022-04-17 14:07:06 UTC
Thanks for expaining, Maik!

I will send a fix later today.

Steve, if you are running on Linux, the following command runs DigiKam with timezone name BST instead:

TZ=GMT0BST,M3.2.0/2:00:00,M11.1.0/2:00:00 digikam

Joerg
Comment 11 joergmlpts 2022-04-17 16:31:47 UTC
Merge request #173 has been created for the fix.

Joerg
Comment 12 caulier.gilles 2022-04-18 04:19:19 UTC
Do not close this file until MR is not pushed in master :

https://invent.kde.org/graphics/digikam/-/merge_requests/173

Gilles
Comment 13 caulier.gilles 2022-04-18 04:20:37 UTC
Also, patch must be applied to qt5-maintenance branch for 7.7.0 release

Gilles
Comment 14 Steve Franks 2022-04-18 11:33:53 UTC
Created attachment 148219 [details]
Metadata and GPX

I'm using Windows at present. The time zone is shown as (UTC+00) Dublin, Edinburgh, Lisbon, London. Daylight Saving Time is on. i.e. BST is GMT+1.
I can't see any reference to Time Zone in either image metadata, or GPX files (from my Garmin GPS Etrex E22x). The metadata appears to only show date and time, the GPS converts times to Zulu (GMT) before exporting the GPX files.
INaturalist seems to only be interested in the date, does that make Timezone irrelevant? The data for my observations https://www.inaturalist.org/observations/111507740 and https://www.inaturalist.org/observations/111909844 don't show times.
iNaturalist does show the time that the observation was made as Apr 18, 2022 · 12:29 BST.
Hope that this helps
Steve
Comment 15 Steve Franks 2022-04-18 11:36:06 UTC
(In reply to joergmlpts from comment #5)
> Steve asks a good question. We are dealing with the timezone of a picture,
> not the system timezone.
> 
> Gilles, is there an editor in DigiKam where one can edit the date and time
> and timezone of a picture?
> 
> Where does the timezone of a picture come from? Will a picture that I took
> in February have a different timezone than a picture that I took yesterday?
> If would think so. So the timezone of a picture is constructed when DigiKam
> loads metadata of a picture? If so, DigiKam gives the picture timezone "GMT
> SUmmer Time".

When I look at my pictures the only difference between GMT and BST is that the latter shows UTC +1:00 if I remember to correctly set daylight saving time on my cameras.
Comment 16 Steve Franks 2022-04-18 11:45:02 UTC
(In reply to Steve Franks from comment #14)
> Created attachment 148219 [details]
> Metadata and GPX
> 
> I'm using Windows at present. The time zone is shown as (UTC+00) Dublin,
> Edinburgh, Lisbon, London. Daylight Saving Time is on. i.e. BST is GMT+1.
> I can't see any reference to Time Zone in either image metadata, or GPX
> files (from my Garmin GPS Etrex E22x). The metadata appears to only show
> date and time, the GPS converts times to Zulu (GMT) before exporting the GPX
> files.
> INaturalist seems to only be interested in the date, does that make Timezone
> irrelevant? The data for my observations
> https://www.inaturalist.org/observations/111507740 and
> https://www.inaturalist.org/observations/111909844 don't show times.
> iNaturalist does show the time that the observation was made as Apr 18, 2022
> · 12:29 BST.
> Hope that this helps
> Steve

Apologies.
I have just noticed that some older observations do have times see:- https://www.inaturalist.org/observations?place_id=any&user_id=serendipterist&verifiable=any
None of the times are shown as BST, some are GMT some UTC
Steve
Comment 17 Maik Qualmann 2022-04-23 11:04:36 UTC
Git commit a254cd10b48a3bdef2424fa2d7d4cee17bad0432 by Maik Qualmann.
Committed on 23/04/2022 at 11:03.
Pushed by mqualmann into branch 'qt5-maintenance'.

Pass observation time in correct format from Joerg Lohse
FIXED-IN: 7.7.0

M  +1    -3    core/dplugins/generic/webservices/inaturalist/inatwindow.cpp

https://invent.kde.org/graphics/digikam/commit/a254cd10b48a3bdef2424fa2d7d4cee17bad0432