Where is Clock in Thunkable X?

Hi everybody!

I’m trying to set it up so that when a button is pressed, it plays a sound based on what day of the week it is. (e.g., If it’s Tuesday, I have a sound that says “Today is Tuesday!”

In the Thunkable classic Android version, this was done with “call Clock1.Now” Is there a similar function in Thunkable X?

The only thing I see in sensors is “Timer”. I thought maybe that would be the same as clock, but after a few hours of spinning my wheels and searching online, I’m still not having success.

Thanks in advance for any help! :slight_smile:

1 Like

Unfortunately the clock is not (yet) available in ThunkableX. :frowning:

See Help/Feature request: Access to device clock / enhanced timer

I am also still hoping there will be a clock component soon, so that I can finish my app. Fingers crossed…

Regards Rob

1 Like

Hi @Rob_Schoemaker,

Thank you for your response! By reading through the thread you linked, I was able to learn about APIs and the timezonedb. :slight_smile:

I’ve made some good progress I think, but I’ve been stumped for a while. If you have a moment, will you help me?

My app has a button that, when pressed, should play a different sound for each day of the month. I think I can do this by getting date info from timezonedb, setting a label’s text to display the date, then have a 31-part if/then block in the play button (if label text says the date is 01, play Sound1, if label text says the date is 02, play Sound2, etc.).

Here are the blocks I have so far:

When the screen starts, we get info from http://api.timezonedb.com/v2/get-time-zone?key=J93B6J5QTQ4M&format=json&by=zone&zone=America/Chicago

The the text in Label1 is set to text from timezonedb’s “formatted” property.

Label 1 now displays “2018-08-18 12:03:02” which is good because the day is in there, but there’s also the year, month, and time, which I don’t need.

I need to figure out a way to have the play button ignore everything except for the day.

Is there a way to tell the play button “Look at the 9th and 10th character of the text in this label…if it’s 01 play Sound1”?

Or maybe there’s a way to tell the label “Only grab the 9th and 10th character from this property and set it as the text?”

Sorry for not quite having all the terminology down yet. Hopefully it comes across! Any ideas?

Thank you!

Hi,

To get a substring (9 and 10 character) from the string, use the block

%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5

Wow! Incredible and so simple! Thanks for your help :slight_smile:

And instead of creating a large number of if–then–else blocks, I would use the filename of the sound to select the sound.

So for example name the files sound01.mp3 (sound for day 1), sound02.mp3 (sound for day 2), etc etc. And then use something like the blocks below to construct the filename to use from the day number that you got from timezonedb:

Saves you a lot of blocks :wink:

Regards Rob

Oh that is so cool! Much better solution than all the if/thens. Thanks for your help Rob!

I’m the same Rob. I’ve built an app on Thunkable Classic for Android, imported from AI2 and it uses Epoch time from the Clock component to seed a random number generator.

I’m interested in building apps for Apple devices hence the interest in the X version.

This workaround using api.timezonedb.com for getting Epoch time looks interesting, so I’ll explore that meantime and hope that the ThunkableX team release a Clock component ASAP.

1 Like