From 7b14449df4db0e1ffd2e12b94f35bae7414c0332 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Thu, 7 Jan 2021 17:14:31 +0100 Subject: [PATCH] Fix one-off error for Histograms: examples: * x0 = -66 and x1 = -64 should yield 65-66 days ago instead of 64-65 days ago * x0 = -2 and x1 = 0 should yield 1-2 days ago instead of 0-1 days ago --- ts/graphs/future-due.ts | 1 - ts/lib/time.ts | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ts/graphs/future-due.ts b/ts/graphs/future-due.ts index 339864f46..6515a11c6 100644 --- a/ts/graphs/future-due.ts +++ b/ts/graphs/future-due.ts @@ -42,7 +42,6 @@ export function gatherData(data: pb.BackendProto.GraphsOut): GraphData { if (isLearning(c)) { const offset = c.due - data.nextDayAtSecs dueDay = Math.floor(offset / 86_400) + 1; - } else { // - testing just odue fails on day 1 // - testing just odid fails on lapsed cards that diff --git a/ts/lib/time.ts b/ts/lib/time.ts index 7ad6c61d7..c3eebefb8 100644 --- a/ts/lib/time.ts +++ b/ts/lib/time.ts @@ -151,8 +151,8 @@ export function dayLabel(i18n: I18n, daysStart: number, daysEnd: number): string }); } else { return i18n.tr(i18n.TR.STATISTICS_DAYS_AGO_RANGE, { - daysStart: Math.abs(daysEnd), - daysEnd: -daysStart - 1, + daysStart: Math.abs(daysEnd - 1), + daysEnd: -daysStart, }); } }