c-klinger / MMM-JsonValue

Extension module for the Magic Mirror allows you to show information from any JSON on your mirror using an HTTP Request to an REST API
MIT License
12 stars 6 forks source link

Ability to format financial data #6

Open mattbryce opened 2 years ago

mattbryce commented 2 years ago

Hi,

I've had the need to format some financial data that my bank returns. The API returns the value in pence, so £250 is returned as "25000" for example.

I've implemented some additional configuration settings and logic whereby it will process the data accordingly. My fork and new branch: https://github.com/mattbryce/MMM-JsonValue/tree/improvement/financial-data

It uses Intl.NumberFormat to format according to the parameters in the config file.

Would be great to merge to main after further testing :)

Thanks

c-klinger commented 2 years ago

Hi @mattbryce, looks like a great improvement. I think we should make it a little bit more general. After first look i'm thinking it might be better to pass the json with all config options to Intl.NumberFormat instead of optimizing them for one use case.

mattbryce commented 2 years ago

Hi @c-klinger, I agree. I'll look at implementing this under my new forked branch... https://github.com/mattbryce/MMM-JsonValue/tree/improvement/value-formatting Thanks