aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/logview/LogFile.cpp
diff options
context:
space:
mode:
authorGravatar Fabio Bas2011-08-13 11:41:46 +0000
committerGravatar Fabio Bas2011-08-13 11:41:46 +0000
commit21375f0d3b7472d29065b0f32c549f80c9025605 (patch)
tree6035964e1338fd115542e0f9e82d35c543baf810 /src/modules/logview/LogFile.cpp
parentworkaround for the second issue of #110 (wordwrap of a long line of text with... (diff)
downloadKVIrc-21375f0d3b7472d29065b0f32c549f80c9025605.tar.gz
KVIrc-21375f0d3b7472d29065b0f32c549f80c9025605.tar.bz2
KVIrc-21375f0d3b7472d29065b0f32c549f80c9025605.zip
fix for #1188 (make the logviewer able to load different date types)
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5927 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/logview/LogFile.cpp')
-rw-r--r--src/modules/logview/LogFile.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/modules/logview/LogFile.cpp b/src/modules/logview/LogFile.cpp
index f9c7d0cb3..098d82636 100644
--- a/src/modules/logview/LogFile.cpp
+++ b/src/modules/logview/LogFile.cpp
@@ -26,6 +26,7 @@
#include "KviQString.h"
#include "KviCString.h"
+#include "KviOptions.h"
#include <QFileInfo>
@@ -77,10 +78,34 @@ LogFile::LogFile(const QString & szName)
m_szNetwork = szUndecoded.hexDecode(szUndecoded.ptr()).ptr();
QString szDate = szTmpName.section('_',-1).section('.',0,-2);
- int iYear = szDate.section('.',0,0).toInt();
- int iMonth = szDate.section('.',1,1).toInt();
- int iDay = szDate.section('.',2,2).toInt();
- m_date.setYMD(iYear,iMonth,iDay);
+ switch(KVI_OPTION_UINT(KviOption_uintOutputDatetimeFormat))
+ {
+ case 1:
+ m_date = QDate::fromString(szDate, Qt::ISODate);
+ break;
+ case 2:
+ m_date = QDate::fromString(szDate, Qt::SystemLocaleDate);
+ break;
+ case 0:
+ default:
+ m_date = QDate::fromString(szDate, "yyyy.MM.dd");
+ break;
+ }
+ if(!m_date.isValid())
+ {
+ // probably the log has been created when the OutputDatetimeFormat option
+ // was set to a different value. Try to guess its format
+ m_date = QDate::fromString(szDate, "yyyy.MM.dd");
+ if(!m_date.isValid())
+ {
+ m_date = QDate::fromString(szDate, Qt::ISODate);
+ if(!m_date.isValid())
+ {
+ m_date = QDate::fromString(szDate, Qt::SystemLocaleDate);
+ // if the date is still not valid, we give up
+ }
+ }
+ }
}
void LogFile::getText(QString & szText)