Searching on dates

Robert Krawitz <rlk-FrUbXkNCsVf2fBVCVOL8/[email protected]>
Newsgroups gmane.comp.kde.kimdaba
Message-ID <20181028031615.59198142F3C@localhost>
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(),
                       m_imageFilePattern->text());

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

-- 
Robert Krawitz                                     <rlk-FrUbXkNCsVf2fBVCVOL8/[email protected]>

***  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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.