14.12.2018, 10:11
(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: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:
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)