diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,6 +174,9 @@ OPTIONAL_COMPONENTS CalendarCore # For Calendar tool. ) +if ("${KF5CalendarCore_VERSION}" VERSION_GREATER 5.6.40) + set(HAVE_KCALENDAR_QDATETIME TRUE) +endif() if(ENABLE_AKONADICONTACTSUPPORT AND NOT KF5AkonadiContact_FOUND) set(ENABLE_KFILEMETADATASUPPORT OFF) diff --git a/app/utils/digikam_config.h.cmake.in b/app/utils/digikam_config.h.cmake.in --- a/app/utils/digikam_config.h.cmake.in +++ b/app/utils/digikam_config.h.cmake.in @@ -75,6 +75,9 @@ /* Define to 1 if you have KCalendar core shared libraries installed */ #cmakedefine HAVE_KCALENDAR 1 +/* Define to 1 if you have KCalendar core shared libraries with QDateTime support installed */ +#cmakedefine HAVE_KCALENDAR_QDATETIME 1 + /* Define to 1 if Panorama tool is supported */ #cmakedefine HAVE_PANORAMA 1 diff --git a/utilities/assistants/calendar/print/calsettings.cpp b/utilities/assistants/calendar/print/calsettings.cpp --- a/utilities/assistants/calendar/print/calsettings.cpp +++ b/utilities/assistants/calendar/print/calsettings.cpp @@ -290,7 +290,13 @@ return; } +#if HAVE_KCALENDAR_QDATETIME + KCalCore::MemoryCalendar::Ptr memCal(new KCalCore::MemoryCalendar(QTimeZone::utc())); + using DateTime = QDateTime; +#else KCalCore::MemoryCalendar::Ptr memCal(new KCalCore::MemoryCalendar(QString::fromLatin1("UTC"))); + using DateTime = KDateTime; +#endif KCalCore::FileStorage::Ptr fileStorage(new KCalCore::FileStorage(memCal, url.toLocalFile(), new KCalCore::ICalFormat)); qCDebug(DIGIKAM_GENERAL_LOG) << "Loading calendar from file " << url.toLocalFile(); @@ -308,9 +314,9 @@ qLast = calSys.date(params.year + 1, 1, 1); qLast = qLast.addDays(-1); - KDateTime dtFirst(qFirst); - KDateTime dtLast(qLast); - KDateTime dtCurrent; + DateTime dtFirst(qFirst, QTime(0, 0)); + DateTime dtLast(qLast, QTime(0, 0)); + DateTime dtCurrent; int counter = 0; KCalCore::Event::List list = memCal->rawEvents(qFirst, qLast);