Condition QDateTimeParser's time-zone parsing on QT_CONFIG(timezone)
It was missing some #if-ery it needed. Change-Id: Ibc12f4a9ee35acb64a39a1c7a15d2934b5710dc0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
d0812cbdab
commit
37c9d6deca
@ -2227,7 +2227,7 @@ static QString qt_tzname(QDateTimePrivate::DaylightStatus daylightStatus)
|
|||||||
#endif // Q_OS_WIN
|
#endif // Q_OS_WIN
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_BOOTSTRAPPED
|
#if QT_CONFIG(datetimeparser) && QT_CONFIG(timezone)
|
||||||
/*
|
/*
|
||||||
\internal
|
\internal
|
||||||
Implemented here to share qt_tzname()
|
Implemented here to share qt_tzname()
|
||||||
@ -2245,7 +2245,7 @@ int QDateTimeParser::startsWithLocalTimeZone(const QStringRef name)
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif // QT_BOOTSTRAPPED
|
#endif // datetimeparser && timezone
|
||||||
|
|
||||||
// Calls the platform variant of mktime for the given date, time and daylightStatus,
|
// Calls the platform variant of mktime for the given date, time and daylightStatus,
|
||||||
// and updates the date, time, daylightStatus and abbreviation with the returned values
|
// and updates the date, time, daylightStatus and abbreviation with the returned values
|
||||||
|
@ -195,9 +195,11 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Preserve zone:
|
// Preserve zone:
|
||||||
v = (tspec == Qt::TimeZone
|
v =
|
||||||
? QDateTime(newDate, newTime, v.timeZone())
|
#if QT_CONFIG(timezone)
|
||||||
: QDateTime(newDate, newTime, tspec, offset));
|
tspec == Qt::TimeZone ? QDateTime(newDate, newTime, v.timeZone()) :
|
||||||
|
#endif
|
||||||
|
QDateTime(newDate, newTime, tspec, offset);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +215,9 @@ int QDateTimeParser::absoluteMax(int s, const QDateTime &cur) const
|
|||||||
{
|
{
|
||||||
const SectionNode &sn = sectionNode(s);
|
const SectionNode &sn = sectionNode(s);
|
||||||
switch (sn.type) {
|
switch (sn.type) {
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
case TimeZoneSection: return QTimeZone::MaxUtcOffsetSecs;
|
case TimeZoneSection: return QTimeZone::MaxUtcOffsetSecs;
|
||||||
|
#endif
|
||||||
case Hour24Section:
|
case Hour24Section:
|
||||||
case Hour12Section: return 23; // this is special-cased in
|
case Hour12Section: return 23; // this is special-cased in
|
||||||
// parseSection. We want it to be
|
// parseSection. We want it to be
|
||||||
@ -248,7 +252,9 @@ int QDateTimeParser::absoluteMin(int s) const
|
|||||||
{
|
{
|
||||||
const SectionNode &sn = sectionNode(s);
|
const SectionNode &sn = sectionNode(s);
|
||||||
switch (sn.type) {
|
switch (sn.type) {
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
case TimeZoneSection: return QTimeZone::MinUtcOffsetSecs;
|
case TimeZoneSection: return QTimeZone::MinUtcOffsetSecs;
|
||||||
|
#endif
|
||||||
case Hour24Section:
|
case Hour24Section:
|
||||||
case Hour12Section:
|
case Hour12Section:
|
||||||
case MinuteSection:
|
case MinuteSection:
|
||||||
@ -766,9 +772,11 @@ QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionIndex,
|
|||||||
text->replace(offset, used, sectiontext.constData(), used);
|
text->replace(offset, used, sectiontext.constData(), used);
|
||||||
break; }
|
break; }
|
||||||
case TimeZoneSection:
|
case TimeZoneSection:
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
result = findTimeZone(sectionTextRef, currentValue,
|
result = findTimeZone(sectionTextRef, currentValue,
|
||||||
absoluteMax(sectionIndex),
|
absoluteMax(sectionIndex),
|
||||||
absoluteMin(sectionIndex));
|
absoluteMin(sectionIndex));
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case MonthSection:
|
case MonthSection:
|
||||||
case DayOfWeekSectionShort:
|
case DayOfWeekSectionShort:
|
||||||
@ -1090,17 +1098,21 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
|
|||||||
int dayofweek = defaultDate.dayOfWeek();
|
int dayofweek = defaultDate.dayOfWeek();
|
||||||
Qt::TimeSpec tspec = defaultValue.timeSpec();
|
Qt::TimeSpec tspec = defaultValue.timeSpec();
|
||||||
int zoneOffset = 0; // In seconds; local - UTC
|
int zoneOffset = 0; // In seconds; local - UTC
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
QTimeZone timeZone;
|
QTimeZone timeZone;
|
||||||
|
#endif
|
||||||
switch (tspec) {
|
switch (tspec) {
|
||||||
case Qt::OffsetFromUTC: // timeZone is ignored
|
case Qt::OffsetFromUTC: // timeZone is ignored
|
||||||
zoneOffset = defaultValue.offsetFromUtc();
|
zoneOffset = defaultValue.offsetFromUtc();
|
||||||
break;
|
break;
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
case Qt::TimeZone:
|
case Qt::TimeZone:
|
||||||
timeZone = defaultValue.timeZone();
|
timeZone = defaultValue.timeZone();
|
||||||
if (timeZone.isValid())
|
if (timeZone.isValid())
|
||||||
zoneOffset = timeZone.offsetFromUtc(defaultValue);
|
zoneOffset = timeZone.offsetFromUtc(defaultValue);
|
||||||
// else: is there anything we can do about this ?
|
// else: is there anything we can do about this ?
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
default: // zoneOffset and timeZone are ignored
|
default: // zoneOffset and timeZone are ignored
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1125,9 +1137,11 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
|
|||||||
{
|
{
|
||||||
const QDate date = actualDate(isSet, year, year2digits, month, day, dayofweek);
|
const QDate date = actualDate(isSet, year, year2digits, month, day, dayofweek);
|
||||||
const QTime time = actualTime(isSet, hour, hour12, ampm, minute, second, msec);
|
const QTime time = actualTime(isSet, hour, hour12, ampm, minute, second, msec);
|
||||||
sect = parseSection(tspec == Qt::TimeZone
|
sect = parseSection(
|
||||||
? QDateTime(date, time, timeZone)
|
#if QT_CONFIG(timezone)
|
||||||
: QDateTime(date, time, tspec, zoneOffset),
|
tspec == Qt::TimeZone ? QDateTime(date, time, timeZone) :
|
||||||
|
#endif
|
||||||
|
QDateTime(date, time, tspec, zoneOffset),
|
||||||
index, pos, input);
|
index, pos, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1152,7 +1166,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
|
|||||||
case TimeZoneSection:
|
case TimeZoneSection:
|
||||||
current = &zoneOffset;
|
current = &zoneOffset;
|
||||||
if (sect.used > 0) {
|
if (sect.used > 0) {
|
||||||
// Synchronize with what findTimeZone() found:
|
#if QT_CONFIG(timezone) // Synchronize with what findTimeZone() found:
|
||||||
QStringRef zoneName = input->midRef(pos, sect.used);
|
QStringRef zoneName = input->midRef(pos, sect.used);
|
||||||
Q_ASSERT(!zoneName.isEmpty()); // sect.used > 0
|
Q_ASSERT(!zoneName.isEmpty()); // sect.used > 0
|
||||||
const QByteArray latinZone(zoneName.toLatin1());
|
const QByteArray latinZone(zoneName.toLatin1());
|
||||||
@ -1162,6 +1176,9 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
|
|||||||
? Qt::TimeZone
|
? Qt::TimeZone
|
||||||
: Qt::OffsetFromUTC)
|
: Qt::OffsetFromUTC)
|
||||||
: (Q_ASSERT(startsWithLocalTimeZone(zoneName)), Qt::LocalTime);
|
: (Q_ASSERT(startsWithLocalTimeZone(zoneName)), Qt::LocalTime);
|
||||||
|
#else
|
||||||
|
tspec = Qt::LocalTime;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Hour24Section: current = &hour; break;
|
case Hour24Section: current = &hour; break;
|
||||||
@ -1319,9 +1336,11 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
|
|||||||
|
|
||||||
const QDate date(year, month, day);
|
const QDate date(year, month, day);
|
||||||
const QTime time(hour, minute, second, msec);
|
const QTime time(hour, minute, second, msec);
|
||||||
return StateNode(tspec == Qt::TimeZone
|
return StateNode(
|
||||||
? QDateTime(date, time, timeZone)
|
#if QT_CONFIG(timezone)
|
||||||
: QDateTime(date, time, tspec, zoneOffset),
|
tspec == Qt::TimeZone ? QDateTime(date, time, timeZone) :
|
||||||
|
#endif
|
||||||
|
QDateTime(date, time, tspec, zoneOffset),
|
||||||
state, padding, conflicts);
|
state, padding, conflicts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1569,6 +1588,7 @@ QDateTimeParser::ParsedSection
|
|||||||
QDateTimeParser::findTimeZone(QStringRef str, const QDateTime &when,
|
QDateTimeParser::findTimeZone(QStringRef str, const QDateTime &when,
|
||||||
int maxVal, int minVal) const
|
int maxVal, int minVal) const
|
||||||
{
|
{
|
||||||
|
#if QT_CONFIG(timezone)
|
||||||
int index = startsWithLocalTimeZone(str);
|
int index = startsWithLocalTimeZone(str);
|
||||||
int offset;
|
int offset;
|
||||||
|
|
||||||
@ -1607,6 +1627,7 @@ QDateTimeParser::findTimeZone(QStringRef str, const QDateTime &when,
|
|||||||
if (index > 0 && maxVal >= offset && offset >= minVal)
|
if (index > 0 && maxVal >= offset && offset >= minVal)
|
||||||
return ParsedSection(Acceptable, offset, index);
|
return ParsedSection(Acceptable, offset, index);
|
||||||
|
|
||||||
|
#endif // timezone
|
||||||
return ParsedSection();
|
return ParsedSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +223,10 @@ private:
|
|||||||
QString *dayName = 0, int *used = 0) const;
|
QString *dayName = 0, int *used = 0) const;
|
||||||
ParsedSection findTimeZone(QStringRef str, const QDateTime &when,
|
ParsedSection findTimeZone(QStringRef str, const QDateTime &when,
|
||||||
int maxVal, int minVal) const;
|
int maxVal, int minVal) const;
|
||||||
static int startsWithLocalTimeZone(const QStringRef name); // implemented in qdatetime.cpp
|
#if QT_CONFIG(timezone)
|
||||||
|
// Implemented in qdatetime.cpp:
|
||||||
|
static int startsWithLocalTimeZone(const QStringRef name);
|
||||||
|
#endif
|
||||||
|
|
||||||
enum AmPmFinder {
|
enum AmPmFinder {
|
||||||
Neither = -1,
|
Neither = -1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user