Bug 301357

Summary: HUB : Support incomplete dates (without time, day, month), like TIFF DateTime supports
Product: [Applications] digikam Reporter: Aleksej <deletesoftware>
Component: Metadata-HubAssignee: Digikam Developers <digikam-bugs-null>
Status: REPORTED ---    
Severity: wishlist CC: caulier.gilles, freddi34, ron, varun.herale
Priority: NOR Keywords: usability
Version: 8.1.0   
Target Milestone: ---   
Platform: macOS (DMG)   
OS: macOS   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: testcase: removed metadata, then ran "ExifTool -DateTime=2005 murka.png"
Derived class for QDateTime

Description Aleksej 2012-06-07 13:38:07 UTC
Old photos scanned from paper often have no precise date or time known, but only with precision of a day, a month, or even a year.  Strangely, e.g. DateTimeOriginal can only be specified with precision no less than that of a second.

digiKam (1.9.0 from Debian testing and 2.6.0rc4 from unstable) doesn’t seem to let me specify a date without time or day or month.  I can add a DateTime property with such precision using ExifTool, and digiKam can read and display it in a sidebar, but it cannot use it as the image’s date, e.g. with the Adjust Time & Date feature: it says the source timestamp is missing.

Reproducible: Always

Steps to Reproduce:
1. Try specifying a date without time, day, or month.

1. Specify such a date directly in the file’s metadata, and try to get digiKam to import it.
Actual Results:  
No luck.

Expected Results:  
Please add support for imprecise dates.

At first I didn’t notice that digiKam cannot use DateTime, but apparently the files I tried with had contained a complete date, too.
Comment 1 caulier.gilles 2012-06-07 14:37:49 UTC
If i understand your request properly, you want to import image with incomplete date time stamp, typically with time value and only date.

If i remember relevant code, when item is imported, we get datetime stamp from metadata and we check if it's valid, typicaly date AND time value are here.

Anyway, if you set date as you want and set time to 00:00:00, it's not enough ? 

Can you share an image with your datetime stamp set in metadata to test in local (if you can attach file to this bugzilla entry)

Gilles Caulier
Comment 2 Aleksej 2012-06-07 16:29:54 UTC
(In reply to comment #1)
> Anyway, if you set date as you want and set time to 00:00:00, it's not
> enough ? 

No, sometimes I don’t know the day of month, or even the month (or even the season).
Comment 3 Aleksej 2012-06-07 16:34:12 UTC
Created attachment 71644 [details]
testcase: removed metadata, then ran "ExifTool -DateTime=2005 murka.png"
Comment 4 Marcel Wiesweg 2012-07-18 19:04:12 UTC
Apparently both Exif and Xmp support incomplete dates. The data structure which we use, QDateTime, does not. There would be several involved to properly solve this wish:

1) General support
 - add a QDateTime derived class to libkexiv2 which support incomplete dates
2) Reading
- add two methods which properly parse incomplete XMP and Exif date strings as described in the relevant specifications
- use these in getImageDateTime
3) Writing
- add methods to format incomplete date strings
- adapt setImageDateTime
4) check database support, probably need to adapt parsing and formatting
5) Support in digikam's UI
6) Support for writing in the edit widgets
Comment 5 Varun Herale 2012-07-20 10:46:04 UTC
@ Marcel -

So when adding a QDateTime derived class to libkexiv2, it must give some default values to the unspecified data. What would be the ideal values for that ?

I mean especially for time values, should the default values be in negative ?
Comment 6 Marcel Wiesweg 2012-07-20 19:49:00 UTC
I'd expect 1/1 00:00

I'd do it like

DateTime : public QDateTime
{
    DateTime(const QDateTime &time) : QDateTime(time) {}
}

and add one member which defines until which field the data is valid (year, month, day, ...)
Comment 7 Varun Herale 2012-07-29 07:05:00 UTC
Created attachment 72810 [details]
Derived class for QDateTime

What about this class structure ? Is this okay ?
Comment 8 Marcel Wiesweg 2012-07-29 12:20:55 UTC
I would do the extra field with flags:

enum ValidFieldFlag
{
HasYear = 1 << 0,
HasMonth = 1 << 1,
HasDay = 1 << 2,
HasHour = 1 << 3,
HasMinute = 1 << 4,
HasSecond = 1 << 5,
HasMicrosecond = 1 << 6,

HasYearOnly = HasYear,
HasYearAndMonthOnly = HasYear | HasMonth
HasDate = HasYear | HasMonth | HasDay
HasTime = HasHour | HasMinute | HasSecond
HasDateTime = HasDate | HasTime
// ... (+subseconds ...)
};
Q_DECLARE_FLAGS(ValidFieldFlags, ValidFieldFlag)
// (declare flags operators outside namespace at the bottom)

ValidFieldFlags validFieldFlags;

// some convenience accessors
bool isComplete() { return (validFieldFlags & HasDateTime) == HasDateTime; }
etc.

// conversion to QDateTime
QDateTime toDateTime() const;
Comment 9 caulier.gilles 2014-09-08 11:47:49 UTC
Varun,

Some progress to write the dedicated class to manage incomplete date in KExiv2 ?

Gilles Caulier
Comment 10 caulier.gilles 2016-03-07 07:20:40 UTC
This entry is illegible for GSoC 2016 project  :

https://community.kde.org/GSoC/2016/Ideas#Project:_digiKam_MetadataHub_improvements
Comment 11 Aleksej 2016-03-08 21:01:50 UTC
> This entry is illegible for GSoC 2016 project :

I think you mean “eligible” https://en.wiktionary.org/wiki/eligible , not https://en.wiktionary.org/wiki/illegible
Comment 12 freddi34 2017-04-11 09:41:46 UTC
Is there any news about this issue? I am also affected, and before I invest significant time working through my scanned photos to add dates (or having to rework them later when this issue is fixed) I want to decide for the right tool. And I would be sad to work-around it with exiftool instead of staying with digikam.

I think the fact that specifications of Exif/Xmp allow incomplete dates is a very strong point that the GUI would better reflect this.

If I set the correct incomplete dates with exiftool, can I then later continue using digikam to manage these photos? Suppose I import these photos (with incomplete set by exiftool) into the digikam database, how does it handle these dates? When I update some tags and write them into the image files, will the dates be affected or overwritten?
Comment 13 freddi34 2017-04-11 12:33:52 UTC
Answer to the third question:
My workflow is now:
(0. Remove complete date if previously set in digikam)
1. Set correct incomplete date using  exiftool. (See http://owl.phy.queensu.ca/~phil/exiftool/faq.html#Q5)
  exiftool -xmp:dateTimeOriginal="1980:09" -xmp:CreateDate="1980:09" "image.jpg"
2. Import image file into digikam. Dates are ignored as invalid and not added to database.
3. Add tags to image and write them to image file. Only metadata from database are written to the image file, dates are not affected.
Comment 14 Ron Braithwaite 2023-08-05 23:56:07 UTC
I need to search for a missing EXIF DateTimeOriginal field and there doesn't appear to be a way to do that.

Many images do not have a value for that field and being able to search and find those images so the field can be filled in is essential.
Comment 15 caulier.gilles 2024-09-17 20:21:54 UTC
Maik,

did you already investigate to support incomplete date to support in digiKam ?

Gilles