This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

sunrise and sunset values
#6
(22.09.2017, 10:24)admin Wrote: You can use rscalc function from common functions to get sunrise and sunset time in minutes. Then you can convert it to text (or use a day/time object instead):
Code:
latitude = 11.11
longitude = 22.22
sunrise, sunset = rscalc(latitude, longitude)

sunrise_hour = math.floor(sunrise / 60)
sunrise_minute = sunrise % 60

sunset_hour = math.floor(sunset / 60)
sunset_minute = sunset % 60

sunrise_text = string.format('%02d:%02d', sunrise_hour, sunrise_minute)
sunset_text = string.format('%02d:%02d', sunset_hour, sunset_minute)


I've checked this script and probably is something wrong. E.g. for Lublin, PL google maps link:
https://www.google.pl/maps/place/Lublin/...4463?hl=pl

Based on this link I've filled the lat and lng:
Code:
lat = 22.4937308
lng = 51.2181956

sunrise, sunset = rscalc(lat, lng)

sunrise_hour = math.floor(sunrise / 60)
sunrise_minute = sunrise % 60

sunset_hour = math.floor(sunset / 60)
sunset_minute = sunset % 60

sunrise_text = string.format('%02d:%02d', sunrise_hour, sunrise_minute)
sunset_text = string.format('%02d:%02d', sunset_hour, sunset_minute)
log(sunrise_text, sunset_text)

The result is wrong:
Code:
* arg: 1
 * string: 04:01
* arg: 2
 * string: 15:35

It should be round about 6:23 for sunrise and 17:03 for sunset.
Reply


Messages In This Thread
sunrise and sunset values - by Thomas - 22.09.2017, 09:46
RE: sunrise and sunset values - by admin - 22.09.2017, 10:24
RE: sunrise and sunset values - by buuuudzik - 25.02.2018, 08:42
RE: sunrise and sunset values - by FatMax - 14.12.2018, 09:37
RE: sunrise and sunset values - by Thomas - 25.09.2017, 09:48
RE: sunrise and sunset values - by admin - 25.09.2017, 10:22
RE: sunrise and sunset values - by Thomas - 04.10.2017, 15:41
RE: sunrise and sunset values - by admin - 25.02.2018, 10:49
RE: sunrise and sunset values - by buuuudzik - 25.02.2018, 11:36
RE: sunrise and sunset values - by admin - 26.02.2018, 07:57
RE: sunrise and sunset values - by buuuudzik - 26.02.2018, 09:20
RE: sunrise and sunset values - by admin - 26.02.2018, 10:26
RE: sunrise and sunset values - by buuuudzik - 26.02.2018, 14:31
RE: sunrise and sunset values - by admin - 27.02.2018, 09:55
RE: sunrise and sunset values - by buuuudzik - 27.02.2018, 11:21
RE: sunrise and sunset values - by admin - 27.02.2018, 11:34
RE: sunrise and sunset values - by buuuudzik - 27.02.2018, 12:17
RE: sunrise and sunset values - by Mrinj - 18.03.2018, 21:52
RE: sunrise and sunset values - by admin - 19.03.2018, 07:08
RE: sunrise and sunset values - by Mrinj - 19.03.2018, 08:30
RE: sunrise and sunset values - by admin - 14.12.2018, 09:41
RE: sunrise and sunset values - by FatMax - 14.12.2018, 10:11
RE: sunrise and sunset values - by YOUSSEF - 29.09.2021, 07:50
RE: sunrise and sunset values - by admin - 29.09.2021, 08:18
RE: sunrise and sunset values - by Dan22 - 22.12.2021, 13:04
RE: sunrise and sunset values - by admin - 22.12.2021, 13:17
RE: sunrise and sunset values - by Dan22 - 22.12.2021, 14:04
RE: sunrise and sunset values - by Dan22 - 25.12.2021, 23:07
RE: sunrise and sunset values - by admin - 27.12.2021, 09:38
RE: sunrise and sunset values - by Dan22 - 28.12.2021, 15:51
RE: sunrise and sunset values - by Daniel - 28.12.2021, 16:06
RE: sunrise and sunset values - by Dan22 - 29.12.2021, 07:32
RE: sunrise and sunset values - by Daniel - 29.12.2021, 10:28
RE: sunrise and sunset values - by Dan22 - 30.12.2021, 10:52
RE: sunrise and sunset values - by Daniel - 30.12.2021, 11:10
RE: sunrise and sunset values - by Dré - 30.10.2022, 16:11
RE: sunrise and sunset values - by admin - 31.10.2022, 06:45
RE: sunrise and sunset values - by Dré - 31.10.2022, 19:21

Forum Jump: