25 #ifndef DIGIKAM_GEO_DATA_PARSER_TIME_H
26 #define DIGIKAM_GEO_DATA_PARSER_TIME_H
37 if (timeString.isEmpty())
47 const int timeStringLength = timeString.length();
48 const int timeZoneSignPosition = timeStringLength-6;
52 int timeZoneOffsetSeconds = 0;
53 const int timeZonePlusPosition = timeString.lastIndexOf(QLatin1Char(
'+'));
54 const int timeZoneMinusPosition = timeString.lastIndexOf(QLatin1Char(
'-'));
56 if ((timeZonePlusPosition == timeZoneSignPosition) ||
57 (timeZoneMinusPosition == timeZoneSignPosition))
59 const int timeZoneSign = (timeZonePlusPosition == timeZoneSignPosition) ? +1 : -1;
63 const QString timeZoneString = timeString.right(6);
65 timeString += QLatin1Char(
'Z');
69 bool okayHour =
false;
70 bool okayMinute =
false;
71 const int hourOffset = timeZoneString.mid(1, 2).toInt(&okayHour);
72 const int minuteOffset = timeZoneString.mid(4, 2).toInt(&okayMinute);
74 if (okayHour && okayMinute)
76 timeZoneOffsetSeconds = hourOffset*3600 + minuteOffset*60;
77 timeZoneOffsetSeconds *= timeZoneSign;
81 QDateTime theTime = QDateTime::fromString(timeString, Qt::ISODate);
82 theTime = theTime.addSecs(-timeZoneOffsetSeconds);
Definition: geolocationedit.cpp:97
QDateTime GeoDataParserParseTime(QString timeString)
Definition: geodataparser_time.h:35