aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/logview
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/logview')
-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
}
}