summaryrefslogtreecommitdiffstats
path: root/qthelper.cpp
diff options
context:
space:
mode:
authorGravatar Giorgio Marzano <marzano.giorgio@gmail.com>2015-10-06 21:08:27 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-18 17:37:49 -0700
commit45b1d0d73db6e2116c6de7113feed381dcc5875f (patch)
treebe00cdcb864e2060192e68c46e7d8d37d9e0805a /qthelper.cpp
parent5d1703cf2c7ebc65ee29e99e40e1c45c4fc1e4ed (diff)
downloadsubsurface-45b1d0d73db6e2116c6de7113feed381dcc5875f.tar.gz
Display day number in trips longer than 1 day
Signed-off-by: Giorgio Marzano <marzano.giorgio@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qthelper.cpp')
-rw-r--r--qthelper.cpp37
1 files changed, 29 insertions, 8 deletions
diff --git a/qthelper.cpp b/qthelper.cpp
index 1b61d4a26..db0649b39 100644
--- a/qthelper.cpp
+++ b/qthelper.cpp
@@ -1043,20 +1043,41 @@ const char *get_dive_date_c_string(timestamp_t when)
return strdup(text.toUtf8().data());
}
-QString get_trip_date_string(timestamp_t when, int nr)
+bool is_same_day(timestamp_t trip_when, timestamp_t dive_when)
+{
+ static timestamp_t twhen = (timestamp_t) 0;
+ static struct tm tmt;
+ struct tm tmd;
+
+ utc_mkdate(dive_when, &tmd);
+
+ if (twhen != trip_when) {
+ twhen = trip_when;
+ utc_mkdate(twhen, &tmt);
+ }
+
+ return ((tmd.tm_mday == tmt.tm_mday) && (tmd.tm_mon == tmt.tm_mon) && (tmd.tm_year == tmt.tm_year));
+}
+
+QString get_trip_date_string(timestamp_t when, int nr, bool getday)
{
struct tm tm;
utc_mkdate(when, &tm);
+ QDateTime localTime = QDateTime::fromTime_t(when);
+ localTime.setTimeSpec(Qt::UTC);
+ QString ret ;
+
if (nr != 1) {
- QString ret = translate("gettextFromC", "%1 %2 (%3 dives)");
- return ret.arg(monthname(tm.tm_mon))
- .arg(tm.tm_year + 1900)
- .arg(nr);
+ if (getday) {
+ ret = localTime.date().toString(dateFormat).append(" (%1 dives)").arg(nr);
+ } else {
+ ret = localTime.date().toString("MMM yy").append(" (%1 dives)").arg(nr);
+ }
} else {
- QString ret = translate("gettextFromC", "%1 %2 (1 dive)");
- return ret.arg(monthname(tm.tm_mon))
- .arg(tm.tm_year + 1900);
+ ret = localTime.date().toString(dateFormat).append(" (1 dive)");
}
+ return ret;
+
}
extern "C" void reverseGeoLookup(degrees_t latitude, degrees_t longitude, uint32_t uuid)