# Open Weather Map Sunrise/Set Parsing

**URL:** https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832
**Category:** Off Topic
**Created:** [March 16, 2021, 4:00pm UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832 "2021-03-16T16:00:43Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)
#### Post date: [March 16, 2021, 4:00pm UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832/1 "2021-03-16T16:00:43Z")

</div>

I’m pulling weather data from Open Weather Map, and am receiving some strange sunrise/sunset data:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/7/27678affb14ab1eb9244321b1b0b6f1569ebc3c1.png)

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

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [March 16, 2021, 4:52pm UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832/2 "2021-03-16T16:52:02Z")

</div>

[Their documentation](https://openweathermap.org/current) lists the sunrise as : “Sunrise time, unix, UTC”. Check these out:

> **[Sunrise and sunset calculations for api weather machine](https://forum.freecodecamp.org/t/sunrise-and-sunset-calculations-for-api-weather-machine/151949)**
>
> So i am doing the api weather machine. I want to display the users sunrise and sunset time. When i call this api, all i get is this number for sunrise: 1507473344. How do i convert this into a time? Is it a location, direction? I switched around two...

> <https://stackoverflow.com/questions/49415666/how-does-one-convert-data-in-api-weather-sunrise-sunset-in-swift-code>

---

<div class="post-metadata">

### Author: ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)
#### Post date: [March 17, 2021, 4:43am UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832/3 "2021-03-17T04:43:44Z")

</div>

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

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [March 17, 2021, 5:34am UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832/4 "2021-03-17T05:34:04Z")

</div>

I’m really good at Googling 🤣 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?

> [@Convert millis to date](https://community.thunkable.com/t/convert-millis-to-date/89953/15):
>
> Hello all, I will make a tutorial on this eventually, but here is an API to convert EPOCH/UNIX time to a timestamp which can help us all organize data more easily. It’s super easy to use and only really requires an HTML request [http://unixtime.co.za/](http://unixtime.co.za/)@Futuredev @CBVG@chris.bailey230698t for example [https://showcase.linx.twenty57.net:8081/UnixTime/fromunix?timestamp=\*\*\*1549874568](https://showcase.linx.twenty57.net:8081/UnixTime/fromunix?timestamp=***1549874568)\*\*\* returns : 2019-02-11 08:42:48 some simple parsing of the respone and ta-da!

---

<div class="post-metadata">

### Author: ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)
#### Post date: [March 17, 2021, 5:43am UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832/5 "2021-03-17T05:43:30Z")

</div>

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

---

<div class="post-metadata">

### Author: ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)
#### Post date: [March 17, 2021, 5:48am UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832/6 "2021-03-17T05:48:18Z")

</div>

Is this API expected to return the time in SS:MM:HH?  
This is what I got:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/b/4b61573d17411c5c8b72cd233e5fbb7dfcfdd33f.png), and when Googling it:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/4/c4a83bf41548925ff95e6f9bc7bf2378c8d95e02.png)

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

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 17, 2021, 6:03am UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832/7 "2021-03-17T06:03:13Z")

</div>

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

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

---

<div class="post-metadata">

### Author: ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)
#### Post date: [March 17, 2021, 6:03am UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832/8 "2021-03-17T06:03:58Z")

</div>

My timezone is IST.

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 17, 2021, 6:07am UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832/9 "2021-03-17T06:07:54Z")

</div>

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

---

<div class="post-metadata">

### Author: ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)
#### Post date: [March 17, 2021, 6:09am UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832/10 "2021-03-17T06:09:45Z")

</div>

> [@muneer](#):
>
> =(1615856126/86400)+Date(1970,1,1)+Time(5,30,0)

Thank you so much! I tested it in Google Sheets, and got back the correct thing, except that the date was wrong:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/c/3c2407dab688c5c2066359a409d9ebaee7d9d347.png)  
It’s actually the 17th…

---

<div class="post-metadata">

### Author: ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)
#### Post date: [March 17, 2021, 6:10am UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832/11 "2021-03-17T06:10:41Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 17, 2021, 6:16am UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832/12 "2021-03-17T06:16:08Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)
#### Post date: [March 17, 2021, 6:17am UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832/13 "2021-03-17T06:17:53Z")

</div>

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

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 17, 2021, 6:20am UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832/14 "2021-03-17T06:20:55Z")

</div>

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

---

<div class="post-metadata">

### Author: ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)
#### Post date: [March 17, 2021, 6:23am UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832/15 "2021-03-17T06:23:03Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 17, 2021, 6:25am UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832/16 "2021-03-17T06:25:33Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)
#### Post date: [March 17, 2021, 6:28am UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832/17 "2021-03-17T06:28:08Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)
#### Post date: [March 17, 2021, 6:38am UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832/18 "2021-03-17T06:38:34Z")

</div>

I’m already stumped.  
This is my Google Sheet:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/2/82e582c44d7b0866b790d03c38669dd497ebfc65.png)

This is my code:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/8/08bae340c69347827792b0eb67e23eb0df5e72c8.png) ’  
I’m not receiving anything in my label. Where did I go wrong?

**EDIT: My updated code still doesn’t work:**

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/2/62586845a80a832d8ace397bda79a54da21cb537.png)

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 17, 2021, 6:53am UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832/19 "2021-03-17T06:53:15Z")

</div>

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

---

<div class="post-metadata">

### Author: ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)
#### Post date: [March 17, 2021, 6:53am UTC](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832/20 "2021-03-17T06:53:55Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/8/089dbaf134ebe8e66d78c7fee6305c3b54500b25.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/f/eff627362fd3ac65b5c19e1b1be13a8ebf018845.png)

[Next page](https://community.thunkable.com/t/open-weather-map-sunrise-set-parsing/1170832.md?page=2)
