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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-03-31 09:30:59 +02:00 committed by bstoeger
parent 916c88ded9
commit dd466d2d48
2 changed files with 3 additions and 2 deletions

View file

@ -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

View file

@ -630,9 +630,9 @@ static std::vector<HistogramAxisEntry> 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));