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

Localisation

ANSWERED

Is toLocaleString() supported? I got the current locale from user-settings with locale.language and I tried to localise the date with toLocaleString(), but it didn't work.

 

How is the date localised in the Fitbit-watchfaces?

Best Answer
1 BEST ANSWER

Accepted Solutions

Sorry, the device only support ES 5.1 JavaScript, and toLocaleDateString() doesn't support the formatting options in this version.

 

View best answer in original post

Best Answer
0 Votes
12 REPLIES 12

I was wondering the same thing. I am able to use toLocaleString() to get commas to appear in my numbers that are greater than 1,000; but date.toLocaleDateString("en-us", { 'weekday': "short" })) and date.toLocaleDateString("en-us", { 'month': "short" }) always returns the date in year-month-day format.

 

Best Answer
0 Votes

Any news on this?

We should localise our apps and watchfaces for publication, so, how should this be done, if .toLocaleDateString() is not supported?

 

My solution is working, but not very elegant...

 

I haven't found anything about localisation in the documentation, so please help...

Best Answer
0 Votes

Sorry, the device only support ES 5.1 JavaScript, and toLocaleDateString() doesn't support the formatting options in this version.

 

Best Answer
0 Votes

Is there a work-around? I want to display the time in HH:MM but not military time. I can slice off the seconds, but I really want 12-hour time.

 

Best Answer
0 Votes

If you've got a Date object, you should be able to use most of the functions listed here.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

I think  

hours %= 12

should do what you want.

Best Answer

Thanks!

Note that if (hours == 12) hours %= 12 returns 0, so

hours = ((hours %= 12) ? 0 : 12);

 

 

Best Answer
0 Votes

Does this work?

I'd have thought

hours = hours === 12 ? hours : hours%12;

 

 

Best Answer
0 Votes
It works for me. I'm new to JavaScript, my background is in C++ and C#, so
things like "===" don't spring to mind yet. Thanks for your help!
Best Answer
0 Votes

(hours+11)%12+1

Peter McLennan
Gondwana Software
Best Answer

So midnight isn't 0 but 12 in 12h format? I didn't know that! 🙈😅

Best Answer
0 Votes

I see now that Versa 2 has a different OS than Versa 3, so i retract my question. Sorry.

Best Answer
0 Votes