mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
ec0fc9d70b
commit
e895374e4b
1 changed files with 7 additions and 1 deletions
|
@ -360,8 +360,14 @@ QString QMLManager::commitChanges(QString diveId, QString date, QString location
|
||||||
date.replace(drop, "");
|
date.replace(drop, "");
|
||||||
}
|
}
|
||||||
newDate = QDateTime::fromString(date, format);
|
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);
|
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);
|
struct dive_site *ds = get_dive_site_by_uuid(d->dive_site_uuid);
|
||||||
char *locationtext = NULL;
|
char *locationtext = NULL;
|
||||||
|
|
Loading…
Add table
Reference in a new issue