46 result = parseDateUnicode(inputString, formatString, calendar, locale, digitSet);
48 result = parseDatePosix(inputString, formatString, calendar, locale, digitSet, formatStandard);
62 result.
year = calendar->
year(QDate::currentDate());
68 }
else if (result.
month > 0 && result.
day > 0) {
91 QString str = inputString.simplified().toLower();
92 QString fmt = formatString.simplified();
96 bool parsedYear =
false;
100 int isoWeekNumber = -1;
101 int dayOfIsoWeek = -1;
107 while (fmt.length() > fmtpos && str.length() > strpos && !error) {
109 QChar fmtChar = fmt.at(fmtpos++);
111 if (fmtChar != QLatin1Char(
'%')) {
113 if (fmtChar.isSpace() && str.at(strpos).isSpace()) {
115 }
else if (fmtChar.toLower() == str.at(strpos)) {
126 if (str.length() > strpos && str.at(strpos).isSpace()) {
130 fmtChar = fmt.at(fmtpos++);
131 if (fmtChar == QLatin1Char(
'E')) {
132 modifierChar = fmtChar;
133 fmtChar = fmt.at(fmtpos++);
136 switch (fmtChar.unicode()) {
141 while (error && j <= calendar->d_ptr->maxDaysInWeek()) {
144 if (str.mid(strpos, longName.length()) == longName) {
145 strpos += longName.length();
147 }
else if (str.mid(strpos, shortName.length()) == shortName) {
148 strpos += shortName.length();
159 while (error && j <= calendar->d_ptr->maxMonthsInYear()) {
168 monthYear = calendar->
year(QDate::currentDate());
177 if (str.mid(strpos, longName.length()) == longName) {
179 strpos += longName.length();
181 }
else if (str.mid(strpos, shortName.length()) == shortName) {
183 strpos += shortName.length();
192 strpos += readLength;
193 error = readLength <= 0;
200 strpos += readLength;
201 error = readLength <= 0;
208 strpos += readLength;
209 error = readLength <= 0;
213 if (modifierChar == QLatin1Char(
'E')) {
214 if (fmtChar == QLatin1Char(
'y')) {
216 strpos += readLength;
217 error = readLength <= 0;
220 j = calendar->eraList()->count() - 1;
221 while (error && j >= 0) {
222 QString subFormat = calendar->eraList()->at(j).format();
223 QString subInput = str.mid(strpos);
224 DateTimeComponents subResult = parseDatePosix(subInput, subFormat, calendar, locale, digitSet, standard);
225 if (!subResult.
error) {
243 strpos += readLength;
244 if (fmtChar == QLatin1Char(
'y')) {
247 error = readLength <= 0;
255 if (modifierChar == QLatin1Char(
'E')) {
256 j = calendar->eraList()->count() - 1;
257 while (error && j >= 0) {
260 if (str.mid(strpos, longName.length()) == longName) {
261 strpos += longName.length();
264 }
else if (str.mid(strpos, shortName.length()) == shortName) {
265 strpos += shortName.length();
274 dayInYear = integerFromString(str.mid(strpos), 3, readLength);
275 strpos += readLength;
276 error = readLength <= 0;
279 isoWeekNumber = integerFromString(str.mid(strpos), 2, readLength);
280 strpos += readLength;
281 error = readLength <= 0;
284 dayOfIsoWeek = integerFromString(str.mid(strpos), 1, readLength);
285 strpos += readLength;
286 error = readLength <= 0;
293 result.
error = error;
330 QString str = inputString.simplified().toLower();
331 QString fmt = formatString.simplified();
335 bool parsedYear =
false;
339 int isoWeekNumber = -1;
340 int dayOfIsoWeek = -1;
347 result.
error = error;
376 int KDateTimeParser::integerFromString(
const QString &
string,
int maxLength,
int &readLength)
const
384 maxLength =
string.length();
387 while (position <
string.length() &&
388 position < maxLength &&
389 string.at(position).isDigit()) {
394 value =
string.left(position).toInt(&ok);
396 readLength = position;