Elapsed time

slik shared this idea 9 years ago
Under Consideration

Hi,


Calculating elapsed time using the GetTime[] command is cumbersome because you need to deal with the elements of the list created.


It would be much easier if there was also a GetComputerTime[] command.


Simon

Comments (11)

photo
1

Hi Simon


If you understand the french language, otherwise Google translator

http://www.geogebra.org/for...

Daniel :wink:

photo
1

Hi Daniel,


Yes I know that GetTime[] gives the date and time. But if list1=start time and list2 =finish time it is not possible to do list2-list1 as there are text as well as numbers in the lists. It's necessary to remove the two text elements and then convert each of the remaining ones to seconds or whichever unit you prefer. Time as a single number in milliseconds would make this much easier, no lists to deal with. :)


Geogebra, as far as I'm aware, uses Java computer time which is a single number in milliseconds.


Simon

photo
1

Hi,what about GetTime[pattern] (pattern compatible with http://php.net/manual/en/fu...)

Then you could do

oldTime=GetTime["\U"]

newTime=GetTime["\U"]

a=0

ParseToNumber[a,newTime"-"oldTime]

(reson of this suggestion is to keep ratio of new functionality / new syntaxes to be as high as possible, just not sure if it is simple enough)

photo
1

Hi,what about GetTime[pattern]


Looks good to me. Would you limit the available patterns or offer many?


Simon

photo
1

This syntax is coming in next beta (4.1.89), just the result is a list which means you have to use

oldTime=GetTime["\U"]

newTime=GetTime["\U"]

a=0

ParseToNumber[a,newTime"-"oldTime]


rather than the code mentioned above.

photo
1

Or how about a classic command called...Delay[<number of millisecond>]?


Tony

photo
1

Zbynek,


Thanks it's much easier than before.

I've been trying to create a start/stop button with this in the script


ParseToNumber[If[a,c,d],GetTime["\U"]]


where I set

a=true

c=0

d=0


But it's not working as expected. I know I can create separate buttons, any other suggestions?


Simon

photo
1

Hi,


with one button this should work:


ParseToNumber[parsed,GetTime["\U"]]

If[a,SetValue[b,parsed],SetValue[c,parsed]]


with initial a=true, b=0,c=0,parsed=0.

photo
1

It doesn't seem to work for a=false, c is not updated


Simon


Edit: My mistake


Thanks again

https://ggbm.at/555095

photo
1

From 4.1.109.0 we've changed the syntax (and it returns a String). You now need to put a \ in front of the codes which makes it a bit more flexible:

http://wiki.geogebra.org/en...


I've edited the posts above to reflect this.

photo
1

button1

=============================================================


SetValue(Ldiffmillisecond,Remove(Ldiffmillisecond,Ldiffmillisecond))

SetValue(Ldiffminute,Remove(Ldiffminute,Ldiffminute))

SetValue(Ldiffsecond,Remove(Ldiffsecond,Ldiffsecond))

SetValue(oldTime,GetTime())

SetValue(newTime,GetTime())

diffmilliseconds=0

diffminutes=0

diffseconds=0

===================================

button2

===================================

SetValue(oldTime,newTime);

SetValue(newTime,GetTime());

diffmilliseconds=(Element(newTime, 3) - Element(oldTime, 3)) 60000 + (Element(newTime, 2) - Element(oldTime, 2)) 1000 + Element(newTime, 1) - Element(oldTime, 1)

SetValue(Ldiffmillisecond,Append(Ldiffmillisecond,diffmilliseconds))

diffminutes=((Element(newTime, 3) - Element(oldTime, 3)) 60000 + (Element(newTime, 2) - Element(oldTime, 2)) 1000 + Element(newTime, 1) - Element(oldTime, 1)) / 60000

SetValue(Ldiffminute,Append(Ldiffminute,diffminutes))

diffseconds=((Element(newTime, 3) - Element(oldTime, 3)) 60000 + (Element(newTime, 2) - Element(oldTime, 2)) 1000 + Element(newTime, 1) - Element(oldTime, 1)) / 1000

SetValue(Ldiffsecond,Append(Ldiffsecond,diffseconds))

Comments have been locked on this page!

© 2021 International GeoGebra Institute