HP Forums
Extract from Time - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Extract from Time (/thread-4913.html)



Extract from Time - Powersoft - 10-10-2015 06:53 PM

Hi all,

Is there a command to convert "Time" to a decimal value?

I need this to calculate the fraction of a day according to "Time"


Cheers

Jan


RE: Extract from Time - Thomas_Sch - 10-10-2015 09:02 PM

Maybe
Code:
HMS→(Time)
?


RE: Extract from Time - cyrille de brébisson - 10-12-2015 06:52 AM

hello,

HMS-> will not do what you think/want.
HMS-> will convert a real number which is represent HMS values (with the decimal part in the [0 to 0,6[ range into a number with a decimal part in the [0..1[ range.

however the Time function does NOT return a number encoded in HMS, but a number DISPLAYED in HMS format (which is different).
To remove the HMS display flag, add that number to 0.
0+Time will return what you want (the 'format' of the first of 2 operands does take precedence over the format of the second one)...

HMS-> functions are there because old habits die hard, but HMS encoding is "bad" (as in crossing the streams"), as base 60 and base 10 conversions always lead to precision lost.
This is why Prime is privileging DISPLAY in HMS with internal encoding staying in decimal.

Cyrille


RE: Extract from Time - Thomas_Sch - 10-12-2015 06:57 AM

Hello Cyrille,

did you try this?
(10-12-2015 06:52 AM)cyrille de brébisson Wrote:  hello,
HMS-> will not do what you think/want.
...
For me HMS-> does the same as "0+".


RE: Extract from Time - Joe Horn - 10-12-2015 08:06 AM

(10-12-2015 06:52 AM)cyrille de brébisson Wrote:  HMS-> will not do what you think/want.
HMS-> will convert a real number which is represent HMS values (with the decimal part in the [0 to 0,6[ range into a number with a decimal part in the [0..1[ range.

I strongly suspect that this is not correct. If it were correct, then HMS→(1.3) would return 1.5 (as on other HP calculators), but it doesn't. HMS→(1.3) returns 1.3, and in general the HMS→ function simply returns any real argument unchanged. All it does is turn off the HMS display flag for HMS-format inputs. That makes it perfect for what the OP wanted, and less cryptic than 0+Time or approx(Time) or evalf(Time) or anything like that.


RE: Extract from Time - cyrille de brébisson - 10-12-2015 03:10 PM

Hello,

Yep, I stand corrected, HMS-> and ->HMS only changes the display flag but does not change the real's value.

Thanks Joe for shining, as always, light on such issues!

Cyrille