moment: Overflow with 12h format.

Not sure if it’s allowed to ask for some help in the github issues this way. If not, feel free to close this issue immediately.

Moment.js is being used in the MagicMirror project. Some users report an issue with the formatting of the time when using a 12 hour format. It gives an overflow issue, printing out a long string of numbers.

It only happens in with the 12 hour format: .format("hh:mm") and only when running on a Raspberry Pi.

See this example: example

The full issue is described here: https://github.com/MichMich/MagicMirror/issues/181

Any help, or pointers would be welcome! Thanks in advance!

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 24 (8 by maintainers)

Most upvoted comments

I’m almost sure that this is caused by Math.pow(10, 1) not returning 10 in your environment. I think the real solution is to not use real math to figure our the padding. I think we should just grab some code from the now totally infamous left pad instead of Math.pow in that padding function.