How did CoaN make that clock project? (Answered)

code
questions
answered

#1

Creation of a Noob published a project that actually connects to real time. I don’t how he did it… but in the code, there are only yellow values (created by the user) which surprised me. Each time you open the project, it starts different.

America, explain.

Edit: Thank you for reminding to tag @CreationsofaNoob


#2

Why don’t you tag CoaN? Like this?
@CreationsOfaNoob

He’d obviously be able to explain how he did it, because he made it.


#3

All I know is it uses the waitTilTimestamp block, a block that was never used but we managed to extract from the app’s code


#4

What @Mr.rex said is correct. If Coan doesn´t answer, try asking @ThinBuffalo.


#5

JS.

JavaScript.

But @CreationsOfaNoob has his ways.


#6

Since @creationSofaNoob isn’t American I don’t think, I guess I’ll just have to explain… :hushed:


While looking in the webplayer code, someone discovered a wait til time stamp block. (It was either me or awesome e)


Sofa Noob uses it to discover each digit of the current Unix timestamp, he has 9(?) rules to determine if the current digit has passed or not. If it has, he increases it by one. If it hasn’t, he decreases it by one and moves on to the next.
He then converts that into a date and time.

I used a laggier version and got just the date.


(The time zone is a bit off)
Mine determines just the hour, which is why it takes so long.


#7

Both of you used it before I saw the code


#9

Thanks for asking @DonnyTheHusky!

I’ll try to explain it simple.

So the WaitTilTimestamp block works like a normal wait block, but you tell it to wait until a certain time and date.

What’s a Timestamp?

You put the time and date in form of a ”Unix timestamp”, which is a number that shows a date by telling how many seconds away it is from 1970.
For example, if you tell it to wait until Unix timestamp 1541980800 (yesterday, November 12) it will just skip the block because that timestamp has already happened. If you put a timestamp for a time in the future, say tomorrow, it will wait until that timestamp and then continue in the code.

That block alone can’t be used for very much, but we can use it to determine which timestamp it is right now. This is what my project does, along with converting the timestamp into a time and date.

Basically, it starts from a variable representing an earlier timestamp. It then increases that variable by a bit and checks if that timestamp has happened. If it has, it repeats this, otherwise it does the same thing but with smaller increments.

If you’d like to see a more in-depth explanation, check out these posts:
https://forum.gethopscotch.com/t/petrichor-i-am/21625/4124?u=creationsofanoob

https://forum.gethopscotch.com/t/petrichor-i-am/21625/4120?u=creationsofanoob


#10

Oh wow this is really cool
I will need to learn more about how this works

I’m thinking of making a game that is different on each day of the week


#11

How manny times owwowowo


#12

That’s a legendary idea :ok_hand:t2:


#13

Make a compass