aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/logview/LogFile.cpp
diff options
context:
space:
mode:
authorGravatar Fabio Bas2011-08-21 21:13:58 +0000
committerGravatar Fabio Bas2011-08-21 21:13:58 +0000
commitbb2b8e60f2c6198fe0c1e44aaed1542ebed01a53 (patch)
tree5cc8861efb623162e41f9dbded8548d3dce67c3b /src/modules/logview/LogFile.cpp
parentfix for #1202 (diff)
downloadKVIrc-bb2b8e60f2c6198fe0c1e44aaed1542ebed01a53.tar.gz
KVIrc-bb2b8e60f2c6198fe0c1e44aaed1542ebed01a53.tar.bz2
KVIrc-bb2b8e60f2c6198fe0c1e44aaed1542ebed01a53.zip
fixed parsing the date of some log files (#1188) + updated deprecated Qt::SystemLocaleDate
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5937 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/logview/LogFile.cpp')
-rw-r--r--src/modules/logview/LogFile.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/modules/logview/LogFile.cpp b/src/modules/logview/LogFile.cpp
index 098d82636..172a1c32b 100644
--- a/src/modules/logview/LogFile.cpp
+++ b/src/modules/logview/LogFile.cpp
@@ -27,6 +27,7 @@
#include "KviQString.h"
#include "KviCString.h"
#include "KviOptions.h"
+#include "KviFileUtils.h"
#include <QFileInfo>
@@ -78,13 +79,28 @@ LogFile::LogFile(const QString & szName)
m_szNetwork = szUndecoded.hexDecode(szUndecoded.ptr()).ptr();
QString szDate = szTmpName.section('_',-1).section('.',0,-2);
+
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);
+ m_date = QDate::fromString(szDate, Qt::SystemLocaleShortDate);
+ if(!m_date.isValid())
+ {
+ // some locale date formats use '/' as a separator; we change them to '-'
+ // when creating log files. Try to reverse that change here
+ QString szUnescapedDate = szDate;
+ szUnescapedDate.replace('-', KVI_PATH_SEPARATOR_CHAR);
+ m_date = QDate::fromString(szUnescapedDate, Qt::SystemLocaleShortDate);
+ if(m_date.isValid())
+ {
+ //qt4 defaults to 1900 for years. So "11" means "1911" instead of "2011".. what a pity
+ if(m_date.year() < 1990)
+ m_date = m_date.addYears(100);
+ }
+ }
break;
case 0:
default:
@@ -101,7 +117,21 @@ LogFile::LogFile(const QString & szName)
m_date = QDate::fromString(szDate, Qt::ISODate);
if(!m_date.isValid())
{
- m_date = QDate::fromString(szDate, Qt::SystemLocaleDate);
+ m_date = QDate::fromString(szDate, Qt::SystemLocaleShortDate);
+ if(!m_date.isValid())
+ {
+ // some locale date formats use '/' as a separator; we change them to '-'
+ // when creating log files. Try to reverse that change here
+ QString szUnescapedDate = szDate;
+ szUnescapedDate.replace('-', KVI_PATH_SEPARATOR_CHAR);
+ m_date = QDate::fromString(szUnescapedDate, Qt::SystemLocaleShortDate);
+ if(m_date.isValid())
+ {
+ //qt4 defaults to 1900 for years. So "11" means "1911" instead of "2011".. what a pity
+ if(m_date.year() < 1990)
+ m_date = m_date.addYears(100);
+ }
+ }
// if the date is still not valid, we give up
}
}