From dd466d2d481d41b2287696ec902992ee2faafd46 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 31 Mar 2024 09:30:59 +0200 Subject: [PATCH] statistics: improve formatting of date axis in day-mode In January it would just show the year for every day. That's silly. Show the year only for Jan 1st. Moreover, it would never show the month, because day-of-month is counted from 1 (whereas month-of-year is counted from 0). Signed-off-by: Berthold Stoeger --- CHANGELOG.md | 1 + stats/statsaxis.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33a1eca28..bda7edf56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +statistics: show proper dates in January desktop: add country to the fields indexed for full text search import: update libdivecomputer version, add support for the Scubapro G3 / Luna and Shearwater Tern desktop: add a button linking to the 'Contribute' page diff --git a/stats/statsaxis.cpp b/stats/statsaxis.cpp index 2eaaee4b8..484ecfaa9 100644 --- a/stats/statsaxis.cpp +++ b/stats/statsaxis.cpp @@ -630,9 +630,9 @@ static std::vector timeRangeToBins(double from, double to) // histogram bins. The entries are the values *between* the histograms. for (auto act = day_from; act <= day_to; inc(act)) { double val = date_to_double(act[0], act[1], act[2]); - if (act[1] == 0) { + if (act[1] == 0 && act[2] == 1) { res.push_back({ QString::number(act[0]), val, true }); - } else if (act[2] == 0) { + } else if (act[2] == 1) { res.push_back({ monthname(act[1]), val, true }); } else { QString s = format.arg(QString::number(act[2]), sep, QString::number(act[1] + 1));