Open Weather Map Sunrise/Set Parsing

I’m pulling weather data from Open Weather Map, and am receiving some strange sunrise/sunset data:
image

I know this isn’t directly related to Thunkable, but does anyone know how to parse these numbers?
Thanks

Their documentation lists the sunrise as : “Sunrise time, unix, UTC”. Check these out:

2 Likes

Thanks @tatiang!

I don’t understand much JS, though, so is there a specific formula to carry out with Thunkable X, so that I can display it in proper time, like 5:13?
Thanks

I’m really good at Googling :rofl: but I don’t always know a ton about each issue. In this case, I think you want an epoch converter. You might search the forums or see if there’s an API that will do that for you.

Like this, maybe?

2 Likes

Thanks again @tatiang! Trying to test @jared 's API out, but the internet has other ideas😀

Is this API expected to return the time in SS:MM:HH?
This is what I got:
image, and when Googling it:
image

Should I read the API the other way around when parsing it?

1 Like

In Google sheet it would be
=(1615856126/86400)+Date(1970,1,1)

You might need to add/subtract the GMT to your local time.

1 Like

My timezone is IST.

1 Like

So it should read in Google sheet as
=(1615856126/86400)+Date(1970,1,1)+Time(5,30,0)

1 Like

Thank you so much! I tested it in Google Sheets, and got back the correct thing, except that the date was wrong:
image
It’s actually the 17th…

1 Like

Also, since I’m receiving my UNIX timestamps from an API, I don’t know what exactly it will be, so how do I keep sending my timestamps to google sheets and getting back the date? Or is there a different(hopefully easier) method?

1 Like

This one is easy because Thunkable is using seconds since 1970 and what I do is connect a Google sheet as my data source and this sheet has two columns
Unix-time and normal-time
In the column normal time I have a formula
=A2/86400+DATE(1970,1,1)+TIME(5,30,0)

Then in Thunkable I update cell A2 and read cell B2 which has my answer.

I use it to compute number of dates between two dates and other date functions.

1 Like

That’s genius! Are these values fixed? DATE(1970,1,1)+TIME(5,30,0)?

1 Like

To convert Thunkable [seconds since 1970] to readable date and time yes it is fixed. Note that the time part is the offset of GMT to your local time so it would be different for different countries but the rest of it is fixed

1 Like

I’ve actually never used Google Sheets as a Data Source. Do I have to create one directly using Google and then connect it to Thunkable? Or can I create a new one directly from Thunkable?

1 Like

Create your sheet from Google. The first row is your field names or column names and then use the Data Sources option in the left pane in Thunkable to connect it as data source and use it as you would have used Airtable or Local Storage.

1 Like

Thanks! I’ve done that. Why am I not able not edit it from within Thunkable? Is this expected? Also, will the CREATE ROW block work even if I can’t directly edit it?

1 Like

I’m already stumped.
This is my Google Sheet:
image

This is my code:


I’m not receiving anything in my label. Where did I go wrong?

EDIT: My updated code still doesn’t work:

1 Like

In your Google sheet add data in the second row.
In Unix time column add the number you have 1615856126
In the second column add the formula =A2…

This should be in the sheet not in Thunkable.

Use Thunkable just to update the number in Unix time

1 Like

Just for testing purposes, I added this code to check whether new rows were actually getting made. They were:


image

1 Like