okular: handle negative dates in okularTime() function

poppler::get_creation_date() and the other date-related functions are not
documented to return such but it happens

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-08-01 04:00:06 +00:00
parent 42d278939a
commit ecbdf67627

View file

@ -13,7 +13,6 @@
#include <qpainter.h>
#include <kaboutdata.h>
#include <klocale.h>
#include <kdatetime.h>
#include <kdebug.h>
#include <kglobal.h>
@ -48,8 +47,12 @@ static QString okularString(const poppler::ustring &popplerstring)
static QString okularTime(const popplertimetype &popplertime)
{
const KDateTime kdatetime(QDateTime::fromTime_t(popplertime));
return KGlobal::locale()->formatDateTime(kdatetime, QLocale::NarrowFormat);
if (popplertime <= 0) {
// -1, i.e. not set
return QString();
}
const QDateTime qdatetime(QDateTime::fromTime_t(popplertime));
return KGlobal::locale()->formatDateTime(qdatetime, QLocale::NarrowFormat);
}
static QDateTime okularDateTime(const popplertimetype &popplertime)