|
|
@ -34,7 +34,7 @@ |
|
|
|
#include <QGlobalStatic> |
|
|
|
#include <QGlobalStatic> |
|
|
|
#include <QHash> |
|
|
|
#include <QHash> |
|
|
|
#include <QMetaObject> |
|
|
|
#include <QMetaObject> |
|
|
|
#include <QRegExp> |
|
|
|
#include <QRegularExpression> |
|
|
|
#include <QStringList> |
|
|
|
#include <QStringList> |
|
|
|
#include <QVariant> |
|
|
|
#include <QVariant> |
|
|
|
#include <QXmlStreamEntityResolver> |
|
|
|
#include <QXmlStreamEntityResolver> |
|
|
@ -391,12 +391,13 @@ namespace |
|
|
|
int nmin = 8; |
|
|
|
int nmin = 8; |
|
|
|
int nsec = 9; |
|
|
|
int nsec = 9; |
|
|
|
// Also accept obsolete form "Weekday, DD-Mon-YY HH:MM:SS ±hhmm"
|
|
|
|
// Also accept obsolete form "Weekday, DD-Mon-YY HH:MM:SS ±hhmm"
|
|
|
|
QRegExp rx("^(?:([A-Z][a-z]+),\\s*)?(\\d{1,2})(\\s+|-)([^-\\s]+)(\\s+|-)(\\d{2,4})\\s+(\\d\\d):(\\d\\d)(?::(\\d\\d))?\\s+(\\S+)$"); |
|
|
|
QRegularExpression rx {"^(?:([A-Z][a-z]+),\\s*)?(\\d{1,2})(\\s+|-)([^-\\s]+)(\\s+|-)(\\d{2,4})\\s+(\\d\\d):(\\d\\d)(?::(\\d\\d))?\\s+(\\S+)$"}; |
|
|
|
|
|
|
|
QRegularExpressionMatch rxMatch; |
|
|
|
QStringList parts; |
|
|
|
QStringList parts; |
|
|
|
if (!str.indexOf(rx)) |
|
|
|
if (str.indexOf(rx, 0, &rxMatch) == 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Check that if date has '-' separators, both separators are '-'.
|
|
|
|
// Check that if date has '-' separators, both separators are '-'.
|
|
|
|
parts = rx.capturedTexts(); |
|
|
|
parts = rxMatch.capturedTexts(); |
|
|
|
const bool h1 = (parts[3] == QLatin1String("-")); |
|
|
|
const bool h1 = (parts[3] == QLatin1String("-")); |
|
|
|
const bool h2 = (parts[5] == QLatin1String("-")); |
|
|
|
const bool h2 = (parts[5] == QLatin1String("-")); |
|
|
|
if (h1 != h2) |
|
|
|
if (h1 != h2) |
|
|
@ -405,9 +406,10 @@ namespace |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Check for the obsolete form "Wdy Mon DD HH:MM:SS YYYY"
|
|
|
|
// Check for the obsolete form "Wdy Mon DD HH:MM:SS YYYY"
|
|
|
|
rx = QRegExp("^([A-Z][a-z]+)\\s+(\\S+)\\s+(\\d\\d)\\s+(\\d\\d):(\\d\\d):(\\d\\d)\\s+(\\d\\d\\d\\d)$"); |
|
|
|
rx = QRegularExpression {"^([A-Z][a-z]+)\\s+(\\S+)\\s+(\\d\\d)\\s+(\\d\\d):(\\d\\d):(\\d\\d)\\s+(\\d\\d\\d\\d)$"}; |
|
|
|
if (str.indexOf(rx)) |
|
|
|
if (str.indexOf(rx, 0, &rxMatch) != 0) |
|
|
|
return QDateTime::currentDateTime(); |
|
|
|
return QDateTime::currentDateTime(); |
|
|
|
|
|
|
|
|
|
|
|
nyear = 7; |
|
|
|
nyear = 7; |
|
|
|
nmonth = 2; |
|
|
|
nmonth = 2; |
|
|
|
nday = 3; |
|
|
|
nday = 3; |
|
|
@ -415,7 +417,7 @@ namespace |
|
|
|
nhour = 4; |
|
|
|
nhour = 4; |
|
|
|
nmin = 5; |
|
|
|
nmin = 5; |
|
|
|
nsec = 6; |
|
|
|
nsec = 6; |
|
|
|
parts = rx.capturedTexts(); |
|
|
|
parts = rxMatch.capturedTexts(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool ok[4]; |
|
|
|
bool ok[4]; |
|
|
@ -463,11 +465,11 @@ namespace |
|
|
|
bool negOffset = false; |
|
|
|
bool negOffset = false; |
|
|
|
if (parts.count() > 10) |
|
|
|
if (parts.count() > 10) |
|
|
|
{ |
|
|
|
{ |
|
|
|
rx = QRegExp("^([+-])(\\d\\d)(\\d\\d)$"); |
|
|
|
rx = QRegularExpression {"^([+-])(\\d\\d)(\\d\\d)$"}; |
|
|
|
if (!parts[10].indexOf(rx)) |
|
|
|
if (parts[10].indexOf(rx, 0, &rxMatch) == 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// It's a UTC offset ±hhmm
|
|
|
|
// It's a UTC offset ±hhmm
|
|
|
|
parts = rx.capturedTexts(); |
|
|
|
parts = rxMatch.capturedTexts(); |
|
|
|
offset = parts[2].toInt(&ok[0]) * 3600; |
|
|
|
offset = parts[2].toInt(&ok[0]) * 3600; |
|
|
|
const int offsetMin = parts[3].toInt(&ok[1]); |
|
|
|
const int offsetMin = parts[3].toInt(&ok[1]); |
|
|
|
if (!ok[0] || !ok[1] || offsetMin > 59) |
|
|
|
if (!ok[0] || !ok[1] || offsetMin > 59) |
|
|
|