mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-27 20:58:47 +00:00
mobile: allow date only when adding/editing dives
Apparently some people try to manually enter older dives where they don't have data about the dive time and therefore want to only capture the dive date. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
ccda4f557c
commit
2886104b1d
1 changed files with 29 additions and 0 deletions
|
@ -965,6 +965,35 @@ bool QMLManager::checkDate(struct dive *d, QString date)
|
|||
if (newDate.isValid())
|
||||
goto parsed;
|
||||
}
|
||||
// if everything else failed - maybe the user is entering dives where they
|
||||
// don't recall the time? So let's try date only patterns...
|
||||
QRegularExpression usDateOnly("\\d+/\\d+/\\d+");
|
||||
if (date.contains(usDateOnly)) {
|
||||
newDate = QDateTime::fromString(date, "M/d/yy");
|
||||
if (newDate.isValid())
|
||||
goto parsed;
|
||||
newDate = QDateTime::fromString(date, "M/d/yyyy");
|
||||
if (newDate.isValid())
|
||||
goto parsed;
|
||||
}
|
||||
QRegularExpression leDateOnly("\\d+\\.\\d+\\.\\d+");
|
||||
if (date.contains(usDateOnly)) {
|
||||
newDate = QDateTime::fromString(date, "d.M.yy");
|
||||
if (newDate.isValid())
|
||||
goto parsed;
|
||||
newDate = QDateTime::fromString(date, "d.M.yyyy");
|
||||
if (newDate.isValid())
|
||||
goto parsed;
|
||||
}
|
||||
QRegularExpression isoDateOnly("\\d+-\\d+-\\d+");
|
||||
if (date.contains(usDateOnly)) {
|
||||
newDate = QDateTime::fromString(date, "yy-M-d");
|
||||
if (newDate.isValid())
|
||||
goto parsed;
|
||||
newDate = QDateTime::fromString(date, "yyyy-M-d");
|
||||
if (newDate.isValid())
|
||||
goto parsed;
|
||||
}
|
||||
}
|
||||
parsed:
|
||||
if (newDate.isValid()) {
|
||||
|
|
Loading…
Reference in a new issue