CommandFusion / iViewer-For-Android

CommandFusion iViewer for Android
2 stars 0 forks source link

strange "toLocaleTimeString" behavior #135

Closed n2hifi closed 10 years ago

n2hifi commented 10 years ago

So try the following code with debugging enabled and Chrome running as debugger:

var d = new Date(); var options = {hour: "numeric", minute: "2-digit"}; CF.setJoin("s1",d.toLocaleTimeString("en-US", options));

I get: 7:25 AM (actually current time but you get the idea) which is what I am going for.

Now if I click 'Run Without Debugger" or I turn debugging off I get:

07:25:35 which is not what I want.

I've tried it a few ways on my Galaxy S2 and my Nexus 7.

toLocaleTimeString("en-US", options) toLocaleTimeString("en-US") toLocaleTimeString()

all of which act differently depending on whether the debugging browser is running. I'm aware that different browsers implement "toLocaleTimeString()" differently but it seems it should be consistent within the program.

fpillet commented 10 years ago

We have no control over toLocaleTimeString(). This is a function implemented by the webkit backend, and I think it is running through OS methods that produce the time string according to the current platform settings.

It is possible that the onboard webkit doesn't honor the options to format the time string. Just in case, try adding the option hour12:true to your options object.

If that doesn't work, you'll have to format the time manually.