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
#22
(14.12.2018, 09:41)admin Wrote: rscalc return values are in minutes starting from 0:00. You can convert these value to timestamps like this:
Code:
12345678910
date = os.date('*t') date.hour = 0 date.sec = 0 date.min = 0 -- timestamp of 0:00 today time = os.time(date) sunrise_time = time + sunrise * 60 sunset_time = time + sunset * 60

That was even less code than what I thought. Thank you!


Code:
1234567891011121314151617181920212223
require('uci') latitude = uci.get('genohm-scada.core.latitude') latitude = tonumber(latitude) longitude = uci.get('genohm-scada.core.longitude') longitude = tonumber(longitude) sunrise, sunset = rscalc(latitude, longitude) date = os.date('*t') date.hour = 0 date.sec = 0 date.min = 0 -- timestamp of 0:00 today time = os.time(date) sunrise_time = time + sunrise * 60 sunset_time = time + sunset * 60 log('Sunrise: ' ..sunrise_time) log('Sunset: ' ..sunset_time)
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: