From 67b7181f522673b05435083ce28106bdfa320e18 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Thu, 9 May 2024 15:50:39 +0200 Subject: [PATCH] Facts: Always render YYYY-MM-DD dates with eight digits in chart tooltips Summary: Always render dates in tooltips when hovering over data points in Burndown charts etc of the Facts application as `YYYY-MM-DD` instead of `YYYY-M-D` by converting the integer to a string and if its length is only one character, prepend a zero. Closes T15819 Test Plan: * Enable the Facts application, go to the Reports of a Project with task changes over time, hover over data points and read the tooltip. * Check Console of web browser's developer tools for no errors. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15819 Differential Revision: https://we.phorge.it/D25630 --- webroot/rsrc/js/application/fact/Chart.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/webroot/rsrc/js/application/fact/Chart.js b/webroot/rsrc/js/application/fact/Chart.js index 473feedcea..991acd7347 100644 --- a/webroot/rsrc/js/application/fact/Chart.js +++ b/webroot/rsrc/js/application/fact/Chart.js @@ -194,9 +194,15 @@ JX.install('Chart', { var d_y = dd.getFullYear(); // NOTE: Javascript months are zero-based. See PHI1017. - var d_m = dd.getMonth() + 1; + var d_m = (dd.getMonth() + 1).toString(); + if (d_m.length == 1) { + d_m = '0' + d_m; + } - var d_d = dd.getDate(); + var d_d = dd.getDate().toString(); + if (d_d.length == 1) { + d_d = '0' + d_d; + } var y = parseInt(d.y1);