Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Decimal and thousands separator for steps( SDK fitbit)

ANSWERED

I could not find an answer to this problem and as I am not a very experienced programmer I was wondering how i can make my steps have a point or a comma. For example 10.256 steps or 10,256 steps. It's a lot nicer than just showing 10256 steps. 

 

I have this code   lblSteps.text = today.local.steps ; but not sure how to make it insert a . or , for steps over a thousand. 

 

Thanks in advance for the help.

 

Kind regards

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

toLocaleString is the key I think ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleStri...)

 

Try something like

 

let stepsCount = today.local.steps ;
lblSteps.text = stepsCount.toLocaleString("en-US");

Number representation being locale dependant. That opens an interesting question into localization support on fitbit OS.

View best answer in original post

Best Answer
4 REPLIES 4

Moving to SDK forum for proper answer. Was originally posted in the Ionic forum.

Work out...eat... sleep...repeat!
Dave | California

Best Answer
0 Votes

toLocaleString is the key I think ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleStri...)

 

Try something like

 

let stepsCount = today.local.steps ;
lblSteps.text = stepsCount.toLocaleString("en-US");

Number representation being locale dependant. That opens an interesting question into localization support on fitbit OS.

Best Answer

Thanks a lot, that did the trick =D!

Best Answer
0 Votes

Edit this is actually working on the watch (but the parameter is ignored, the local formatting is always used)


This is actually not working for languages other than US it seems. It will only show "," regardless of the user preferences.

 

I'm also curious as to how formatting should be done. The Layers default watchface will correctly separate thousands according to the locale

Best Answer
0 Votes