| Summary: | Invalid date warnings when browsing CVS | ||
|---|---|---|---|
| Product: | [Applications] cervisia | Reporter: | Krzysztof Kapuscik <saveman> |
| Component: | general | Assignee: | Christian Loose <christian.loose> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Fedora RPMs | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Krzysztof Kapuscik
2007-07-24 12:33:20 UTC
SVN commit 711210 by mkoller:
BUG: 148162
Qt-3.3.8 changed the parsing in QDateTime::fromString() but introduced
a bug which leads to the problem that days with 1 digit will incorrectly being
parsed as day 0 - which is invalid.
workaround with the implementation from Qt-3.3.6
M +51 -1 updateview_items.cpp
--- branches/KDE/3.5/kdesdk/cervisia/updateview_items.cpp #711209:711210
@@ -24,6 +24,7 @@
#include <qdir.h>
#include <qpainter.h>
+#include <qregexp.h>
#include <kdebug.h>
#include <kglobalsettings.h>
@@ -246,7 +247,54 @@
return (it != m_itemsByName.end()) ? *it : 0;
}
+// Qt-3.3.8 changed the parsing in QDateTime::fromString() but introduced
+// a bug which leads to the problem that days with 1 digit will incorrectly being
+// parsed as day 0 - which is invalid.
+// workaround with the implementation from Qt-3.3.6
+QDateTime parseDateTime(const QString &s)
+{
+ static const char * const qt_shortMonthNames[] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+ QString monthName( s.mid( 4, 3 ) );
+ int month = -1;
+ // Assume that English monthnames are the default
+ for ( int i = 0; i < 12; ++i ) {
+ if ( monthName == qt_shortMonthNames[i] ) {
+ month = i + 1;
+ break;
+ }
+ }
+ // If English names can't be found, search the localized ones
+ if ( month == -1 ) {
+ for ( int i = 1; i <= 12; ++i ) {
+ if ( monthName == QDate::shortMonthName( i ) ) {
+ month = i;
+ break;
+ }
+ }
+ }
+ if ( month < 1 || month > 12 ) {
+ qWarning( "QDateTime::fromString: Parameter out of range" );
+ QDateTime dt;
+ return dt;
+ }
+ int day = s.mid( 8, 2 ).simplifyWhiteSpace().toInt();
+ int year = s.right( 4 ).toInt();
+ QDate date( year, month, day );
+ QTime time;
+ int hour, minute, second;
+ int pivot = s.find( QRegExp(QString::fromLatin1("[0-9][0-9]:[0-9][0-9]:[0-9][0-9]")) );
+ if ( pivot != -1 ) {
+ hour = s.mid( pivot, 2 ).toInt();
+ minute = s.mid( pivot+3, 2 ).toInt();
+ second = s.mid( pivot+6, 2 ).toInt();
+ time.setHMS( hour, minute, second );
+ }
+ return QDateTime( date, time );
+}
+
// Format of the CVS/Entries file:
// /NAME/REVISION/[CONFLICT+]TIMESTAMP/OPTIONS/TAGDATE
@@ -304,7 +352,9 @@
}
else
{
- const QDateTime date(QDateTime::fromString(timestamp)); // UTC Time
+ // workaround Qt-3.3.8 bug with our own function (see function above)
+ // const QDateTime date(QDateTime::fromString(timestamp)); // UTC Time
+ const QDateTime date(parseDateTime(timestamp)); // UTC Time
QDateTime fileDateUTC;
fileDateUTC.setTime_t(entry.m_dateTime.toTime_t(), Qt::UTC);
if (date != fileDateUTC)
|