Page MenuHomePhorge

Facts: Always render YYYY-MM-DD dates with eight digits in chart tooltips
ClosedPublic

Authored by aklapper on May 9 2024, 13:50.

Details

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.

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

aklapper requested review of this revision.May 9 2024, 13:50

✅ Number.prototype.toString() supported by all browser webs https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString

✅ Surprisingly, in 2024, JavaScript still requires people to run padStart() and does not have any intelligent format

Any person with Internet Exploder here, to double-check?

Anyway d_d is the best variable every.


I think somebody here would propose to avoid padStart() and be boring:

if (d_m.length < 2) {
  d_m = '0' + d_m;
}

But if you are running a 2016 browser web, without any update, you are in trouble, dear reading friend. Better to explode here so we can catch your bug report and save your life, recommending a browser update. So, +1.

This revision is now accepted and ready to land.May 9 2024, 16:29

I think somebody here would propose to avoid padStart() and be boring:

if (d_m.length < 2) {
  d_m = '0' + d_m;
}

That's so simple that I did not even think of it, heh.

But if you are running a 2016 browser web, without any update, you are in trouble

Sure but it's not necessarily your own decision which software versions your company forces you to use on their "managed" systems, or how much money you have to buy newer hardware or operating systems which allow newer browser versions. So I think I prefer your boring version. Thanks for sharing it!

Use standard JS string concatenation instead of shiny padStart() because better backwards compatibility

The coffee on my desk doesn't seem to work yet - use a proper comparison.

(If it does not work you may still need to call .toString() before doing this)

Garrr I am so sure I had tested it this morning but maybe I was sleepwalking? Tested again now and seems to work, thanks