Bad Arguments on Clock Duration

I'm getting Bad Argument error when checking for a duration using the clock app. I have used the clock app to build both of the arguments, so it seems I must be missing something. I've tried a number of different variations on creating the starting instant, but here's where I'm at now. Hopefully someone can see what I'm missing.

Here is the block where I create the FV1StartInstant value stored in TinyDB:

Here is the block where I check the duration. It is comparing the FV1StartInstant with Clock1.Now:
image

Here is the bad argument error I am getting. Any ideas?

Your TinyDB default value, 0, is not an Instant.
The Duration block only accepts Instants.

Try a different notfound value, like Now().

So I definitely like the Now() option better, but unfortunately it doesn't help. I added it and still get the same error.

What my pictures don't show is that the duration is nested in an IF statement that only runs it the TinyDB returns a value, so it can't get to this block if there is no value, so it really can't hit the default value.

As you can see in the error dialogue it shows the arguments as two java.GregorianCalendar values.

Show us the big picture?


Please export your project and post it here.

1 Like

Another possibility is to store time as Milliseconds from 1970, a big number.
There are clock blocks to convert back and forth, and it is math-friendly.

TankTracker.aia (12.0 KB)

You are not wrong, this should work....

but it errors out

1 Like

So don't rely on TinyDB for Instant storage, only store milliseconds.

Also see FAQ Section: Screens
for proper screen switching techniques.
Reopening Screen1 will fill RAM eventually.
(Your blocks)

1 Like

Do it like this:

Thanks, I changed my Open Screen1 functions to Close Screen functions, that seems to work ok and I think takes care of the RAM issue. I still need to add my Close Application.

So I'm doing it this way and for some reason I'm getting 0 as the result every single time. I'm having a harder than normal time tracking that down though because I can't use the companion app or emulators when I'm at work and have to build the APK for testing. I'll try some more when I get home tonight.

Try this: