finding non-realtime values between events (not timer)

Aug 10, 2010 at 6:00pm

finding non-realtime values between events (not timer)

I have a program that is generating h:m:s GMT when an event occurs. I am using [timer] to time the (realtime) seconds between events. That works fine.

The problem I’m having is when going through the data “offline”. [timer] then outputs the value between events that I generate manually. So for testing this method is useless.

So here’s the question: My program provides me with (for example) 12:10pm 05s. The next value is 11:13pm 54s. How can I find the seconds value between them?

#51744
Aug 10, 2010 at 11:01pm

Can you post that bit of your patch? Probably something you can do with storing the value, sprintf, and maybe translate i’m guessing.
-Ben

#185638
Aug 11, 2010 at 9:09pm

[- ] ?

#185639
Aug 12, 2010 at 2:00am

My first question would be, why not store the time between events (which you say you’re measuring with timer as the events occur in real time) as part of your data set, instead of storing only the GMT?

You could also use the ‘ticks’ message to the date object when you first record the events, and store that info, which would be accurate to the nearest 1/60 of a second.

But if you’re somehow in a situation where the only information you have is the GMT in the format you describe, you should use regexp to parse out the numbers and the am/pm info, then do the proper math to convert that to seconds, then subtract it from the previous time (as Roman suggests). Here’s an example to get you started. (It only works for delta times up to 24 hours — 86400 seconds — because you don’t include date info in your GMT data.)

– Pasted Max Patch, click to expand. –
#185640

You must be logged in to reply to this topic.