2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 22:46:10 +00:00

Added support of weekly range of days to chart views.

This commit is contained in:
23rd
2023-10-11 07:03:49 +03:00
committed by John Preston
parent 0dec803177
commit c9c82446cb
5 changed files with 41 additions and 11 deletions

View File

@@ -76,11 +76,13 @@ void FillLineColorsByKey(Data::StatisticalChart &chartData) {
const auto leftDateTime = QDateTime::fromSecsSinceEpoch(
leftTimestamp / 1000);
const auto leftText = QLocale().toString(leftDateTime.date(), formatter);
if (xIndexMin == xIndexMax) {
if ((xIndexMin == xIndexMax) && !chartData.weekFormat) {
return leftText;
} else {
const auto rightDateTime = QDateTime::fromSecsSinceEpoch(
chartData.x[xIndexMax] / 1000);
constexpr auto kSevenDays = 3600 * 24 * 7;
const auto rightDateTime = QDateTime::fromSecsSinceEpoch(0
+ (chartData.x[xIndexMax] / 1000)
+ (chartData.weekFormat ? kSevenDays : 0));
return leftText
+ ' '
+ QChar(8212)