<p>I am making a watch app, where I need to know where there is currently sun, and where it's not.</p>
<p>I need to have some sort of formula/function to insert: date, time and longitude, and get back the latitude of the civil twilight.</p>
<p>How can I do this?</p>

CC BY-SA 4.0
2021-06-22T18:54:08.047Z
Could you maybe explain it a bit clearer? As far as I understand, you want to draw an area on the world map where there is currently civil twilight. But you must know that such area isn't a line, but is an area, so you would get inequation. The places in civil twilight have Sun between -6° and 0° of altitude.
User123
CC BY-SA 4.0
2021-06-22T21:43:26.243Z
Yes, well, i dont really need it to be that specific. the worldmap is 200px x 100px, as it is going to be shown on a wristwatch. I just want to make something with this kind of effect, just way smaller: https://i.ytimg.com/vi/fDJrih_rAUc/maxresdefault.jpg
patchie
CC BY-SA 4.0
2021-06-22T22:58:01.067Z
How will this factor in the height above sea level of the observer? It's still sunny on a mountaintop when the Sun has set for those on the plain... (I'm sure there's a deeper philosophical meaning here!).
Chappo Hasn't Forgotten
CC BY-SA 4.0
2021-06-23T03:06:34.537Z
Related: https://astronomy.stackexchange.com/q/39670/16685 My answer there has Python code that calculates sunrise time, and it can be modified to compute sunset time, if you understand the Equation of Time. However, that code uses a very crude formula for the Sun's position, I have a more accurate formula here: https://astronomy.stackexchange.com/a/40243/16685
PM 2Ring
CC BY-SA 4.0
2021-06-23T03:12:04.897Z
BTW, calculating the exact time of sunrise, sunset, and the various [twilights](https://en.wikipedia.org/wiki/Twilight) is tricky. As chappo mentioned, you need to take the local geography into account, and atmospheric refraction, which is rather large for celestial bodies near the horizon.
PM 2Ring
<earth><python><sunrise><sunset><twilight>
What is the formula to input date, time and longitude. Where I can get latitude of the civil twilight back?
patchie
# What is the formula to input date, time and longitude. Where I can get latitude of the civil twilight back?

(Asked by: username_0 on 2021-06-22)

I am making a watch app, where I need to know where there is currently sun, and where it's not.

I need to have some sort of formula/function to insert: date, time and longitude, and get back the latitude of the civil twilight.

How can I do this?

**Tags:** earth, python, sunrise, sunset, twilight
> **Comments:**
> **username_1**: Could you maybe explain it a bit clearer? As far as I understand, you want to draw an area on the world map where there is currently civil twilight. But you must know that such area isn't a line, but is an area, so you would get inequation. The places in civil twilight have Sun between -6° and 0° of altitude.  
> **username_0**: Yes, well, i dont really need it to be that specific. the worldmap is 200px x 100px, as it is going to be shown on a wristwatch. I just want to make something with this kind of effect, just way smaller: https://i.ytimg.com/vi/fDJrih_rAUc/maxresdefault.jpg  
> **username_2**: How will this factor in the height above sea level of the observer? It's still sunny on a mountaintop when the Sun has set for those on the plain... (I'm sure there's a deeper philosophical meaning here!).  
> **username_3**: Related: https://astronomy.stackexchange.com/q/39670/16685 My answer there has Python code that calculates sunrise time, and it can be modified to compute sunset time, if you understand the Equation of Time. However, that code uses a very crude formula for the Sun's position, I have a more accurate formula here: https://astronomy.stackexchange.com/a/40243/16685  
> **username_3**: BTW, calculating the exact time of sunrise, sunset, and the various [twilights](https://en.wikipedia.org/wiki/Twilight) is tricky. As chappo mentioned, you need to take the local geography into account, and atmospheric refraction, which is rather large for celestial bodies near the horizon.  

---

## 0 answers

