aboutsummaryrefslogtreecommitdiffstats
path: root/qt-mobile/qmlmanager.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-27 12:07:10 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-27 15:07:10 -0800
commite895374e4b4dc119a4b45cf2d0f8a50eb6aa89b1 (patch)
treebd05340b378e1f95502069a402ee71a6c0792bbc /qt-mobile/qmlmanager.cpp
parentec0fc9d70b679b854fb50d685a5dcfe6f1bf7093 (diff)
downloadsubsurface-e895374e4b4dc119a4b45cf2d0f8a50eb6aa89b1.tar.gz
QML UI: fix Qt's broken handling of two digit years in dates
Because dives in 1912 are unlikely to be added to my dive log... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-mobile/qmlmanager.cpp')
-rw-r--r--qt-mobile/qmlmanager.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp
index e80c2c082..5503b3ca3 100644
--- a/qt-mobile/qmlmanager.cpp
+++ b/qt-mobile/qmlmanager.cpp
@@ -360,8 +360,14 @@ QString QMLManager::commitChanges(QString diveId, QString date, QString location
date.replace(drop, "");
}
newDate = QDateTime::fromString(date, format);
- if (newDate.isValid())
+ if (newDate.isValid()) {
+ // stupid Qt... two digit years are always 19xx - WTF???
+ // so if adding a hundred years gets you into something before a year from now...
+ // add a hundred years.
+ if (newDate.addYears(100) < QDateTime::currentDateTime().addYears(1))
+ newDate = newDate.addYears(100);
d->dc.when = d->when = newDate.toMSecsSinceEpoch() / 1000 + gettimezoneoffset(newDate.toMSecsSinceEpoch() / 1000);
+ }
}
struct dive_site *ds = get_dive_site_by_uuid(d->dive_site_uuid);
char *locationtext = NULL;