[KPhotoAlbum] Searching on dates

Robert Krawitz rlk at alum.mit.edu
Sun Oct 28 03:16:15 GMT 2018

One thing that has long annoyed me is that the end date of a search is
not inclusive.  So for example if you search with the same start and
end date, you don't get anything at all.

The fix, of course, is trivial; any objections if I push it?

diff --git a/AnnotationDialog/Dialog.cpp b/AnnotationDialog/Dialog.cpp
index e98e989d..b72c52bc 100644
--- a/AnnotationDialog/Dialog.cpp
+++ b/AnnotationDialog/Dialog.cpp
@@ -780,7 +780,7 @@ DB::ImageSearchInfo AnnotationDialog::Dialog::search( DB::ImageSearchInfo* searc
     int ok = exec();
     if ( ok == QDialog::Accepted )  {
         const QDateTime start = m_startDate->date().isNull() ? QDateTime() : QDateTime(m_startDate->date());
-        const QDateTime end = m_endDate->date().isNull() ? QDateTime() : QDateTime( m_endDate->date() );
+        const QDateTime end = m_endDate->date().isNull() ? QDateTime() : QDateTime( m_endDate->date() ).addDays(1).addMSecs(-1);
         m_oldSearch = DB::ImageSearchInfo( DB::ImageDate( start, end ),
                       m_imageLabel->text(), m_description->toPlainText(),

(Incidentally, I note that searching on date is very slow...it will be
interesting to dig into that.)

Robert Krawitz                                     <rlk at alum.mit.edu>

***  MIT Engineers   A Proud Tradition   http://mitathletics.com  ***
Member of the League for Programming Freedom  --  http://ProgFree.org
Project lead for Gutenprint   --    http://gimp-print.sourceforge.net

"Linux doesn't dictate how I work, I dictate how Linux works."
--Eric Crampton

More information about the Kphotoalbum mailing list