From 52a77344d9ad5eb96508ffbad9b7213c94f5c820 Mon Sep 17 00:00:00 2001 From: Simon Brunel Date: Wed, 9 Jan 2019 20:30:12 +0100 Subject: [PATCH] Fix detection of tooltip fallback format Use `adapter.startOf(ts, 'day') !== ts` instead of introducing a new adapter API to detect when the timestamp is midnight in the current timezone. --- src/scales/scale.time.js | 2 +- test/specs/scale.time.tests.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/scales/scale.time.js b/src/scales/scale.time.js index 96ecff48817..6cf481b4ce2 100644 --- a/src/scales/scale.time.js +++ b/src/scales/scale.time.js @@ -419,7 +419,7 @@ function determineLabelFormat(timestamps) { if (ts % INTERVALS.second.size !== 0) { return presets.full; } - if (ts % INTERVALS.day.size !== 0) { + if (!hasTime && adapter.startOf(ts, 'day') !== ts) { hasTime = true; } } diff --git a/test/specs/scale.time.tests.js b/test/specs/scale.time.tests.js index 192ec8229c3..c5be682d95d 100755 --- a/test/specs/scale.time.tests.js +++ b/test/specs/scale.time.tests.js @@ -662,8 +662,8 @@ describe('Time scale tests', function() { datasets: [{ xAxisID: 'xScale0', data: [ - {t: +new Date('2018-01-08 00:00:00Z'), y: 10}, - {t: +new Date('2018-01-09 00:00:00Z'), y: 3} + {t: +new Date('2018-01-08 00:00:00'), y: 10}, + {t: +new Date('2018-01-09 00:00:00'), y: 3} ] }], },