Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Up level
What's New
4/16/13 - "Harmony Ultimate" hybrid touchscreen and "Harmony Smart Control" models join the ranks.
4/15/13 - Convenient $150 hard buttoned remote for use with Apple iPhone or iPad-based control systems.
1/24/13 - Disappointing Q3 earnings due to flagging global PC market to blame.
12/31/12 - Our thanks to everyone who has helped make Remote Central a great community for the past year!
12/25/12 - Got a new remote? Want a new remote? Explore Remote Central's resources!

Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Topic:
DONE - bug in system time string (24h format)
This thread has 6 replies. Displaying all posts.
Post 1 made on Monday November 9, 2009 at 05:25
multimedia
Long Time Member
Joined:
Posts:
December 2006
110
There seems to be a bug in the system time string (only 24h format):

The command GUI.getDisplayTime() will return a string, as it is shown in the display.

The command
GUI.getDisplayTime().substring(0,2)
returns the first two digits as a string.

If you want to convert this string to an interger the command
parseInt(GUI.getDisplayTime().substring(0,2))
will return
6 at 06:xx
7 at 07:xx
0 at 08:xx (which is not correct)
0 at 09:xx (which is not correct)
10 at 10:xx

As a workaround, the command
parseInt(GUI.getDisplayTime().substring(2,1))
returns always the correct second digit.

I used:
PEP2 newest release
Newest Firmware
9600 and 9400 same behaviour

Last edited by multimedia on November 9, 2009 06:36.
Post 2 made on Monday November 9, 2009 at 05:46
Sogliphy
Long Time Member
Joined:
Posts:
July 2007
181
On November 9, 2009 at 05:25, multimedia said...

If you want to convert this string to an interger the command
parseInt(GUI.getDisplayTime().substring(0,2))
will return
6 at 06:xx
7 at 07:xx
0 at 08:xx (which is not correct)
0 at 09:xx (which is not correct)
10 at 10:xx


This has nothing to do with GUI.getDisplayTime(); the following:

parseInt("08");

will also return 0.

What happens is that parseInt will treat a string with a leading zero as an octal value; you need to force it to interpret the string as a decimal integer:

parseInt("08", 10);

will return 8.

Last edited by Sogliphy on November 9, 2009 05:54.
OP | Post 3 made on Monday November 9, 2009 at 06:01
multimedia
Long Time Member
Joined:
Posts:
December 2006
110
thx sogliphy,

obviously my javascript experience is to improve.
Didn't remember that parseInt is also converting formats.
Post 4 made on Monday November 9, 2009 at 22:16
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
11,540
There's also a quick way to extract time that also handles either 12hr or 24hr format using RegExp. I posted this method quite a long time ago.

[Link: remotecentral.com]

You can check ampm for non-null and not empty string and if this holds true, you can bet the remote is set for 24 hour format.

In the case of 24 hour clock, hour === 0 is midnight and hour===12 is noon.

You should be able to work out other details but RegExp is my preferred approach to all this string parsing. With one fell swoop, you can get hour, minute and ampm (if a 12 hour clock).
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 5 made on Tuesday November 10, 2009 at 09:02
Sogliphy
Long Time Member
Joined:
Posts:
July 2007
181
On November 9, 2009 at 06:01, multimedia said...
thx sogliphy,

obviously my javascript experience is to improve.
Didn't remember that parseInt is also converting formats.

parseInt always converts formats -even for decimal numbers-, it interprets a text string as a number, using a number format which is either auto-detected or specified explicitly, into an internal representation for a number.

For example,

var text = "1020304050607080901";
System.print(text);
System.print(parseInt(text));

results in:

1020304050607080901
1020304050607081000

The first line is the original text string.

The second line is the result of converting the original text string (ending in "0901"), to the internal number representation, and converting that back to a decimal string representation of the number. The amount of significant digits in the decimal number in the text string is too large to fit in JavaScript's internal representation, so there is some loss of accuracy.
Post 6 made on Tuesday November 10, 2009 at 15:09
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
11,540
Nice catch. Yes, parseInt implies that you are parsing 32 bits and will adhere to that. However, var x = Number("1020304050607080901") should work.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 7 made on Thursday November 12, 2009 at 07:29
Sogliphy
Long Time Member
Joined:
Posts:
July 2007
181
On November 10, 2009 at 15:09, Lyndel McGee said...
Nice catch. Yes, parseInt implies that you are parsing 32 bits and will adhere to that. However, var x = Number("1020304050607080901") should work.

System.print(new Number("1020304050607080901"));

also yields 1020304050607081000.

The JavaScript internal number representation, as defined by section 8.5 of the ECMA-262 edition 3 standard, is not able to represent integers larger than 9007199254740992 without losing precision.


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse