hardwired wrote: ↑August 18th, 2022, 6:28 pm
Thanks a lot SilverAzide, I'm looking for leading zeros in 24 hour format.

This time I am the one being a little bit late, but have been in a short vacation, so even thought I saw your posts, couldn't reply to them properly.

First question is which skin are you exactly using, because there have been uploaded more of them over time.

If you're using my skin, posted

here, you have more possibilities. For instance to get the Sunrise and Sunset with leading zeros, you have to modify the TimeSunrise and TimeSunset functions of the Sun.lua script file this way:

Code: Select all

```
-- compute the times of Sunrise
function TimeSunrise(Longitude, Latitude, MTSR, DS, ET)
local TSR
TSR = MTSR-(180/math.pi)*math.asin(math.tan(DS*math.pi/180)*math.tan(Latitude*math.pi/180))
TSR = 24*TSR/360+TimezoneOffset
local SunRiseHour = math.floor(TSR)
local SunRiseMinutes = math.floor(60*(TSR-math.floor(TSR)))
if (SunRiseHour <= 9) then
SKIN:Bang('!SetVariable', 'TimeSR', '0'..SunRiseHour..':'..SunRiseMinutes)
else
SKIN:Bang('!SetVariable', 'TimeSR', SunRiseHour..':'..SunRiseMinutes)
end
end
-- compute the times of Sunset
function TimeSunset(Longitude, Latitude, MTSS, DS, ET)
local TSS
TSS = MTSS+(180/math.pi)*math.asin(math.tan(DS*math.pi/180)*math.tan(Latitude*math.pi/180))
TSS = 24*TSS/360+TimezoneOffset
local SunSetHour = math.floor(TSS)
local SunSetMinutes = math.floor(60*(TSS-math.floor(TSS)))
if (SunSetHour <= 9) then
SKIN:Bang('!SetVariable', 'TimeSS', '0'..SunSetHour..':'..SunSetMinutes)
else
SKIN:Bang('!SetVariable', 'TimeSS', SunSetHour..':'..SunSetMinutes)
end
end
```

To do the same for the Moonrise and Moonset, you have to alter the test_moon function of the Moon.lua script this way:

Code: Select all

```
function test_moon(k, t0, lat, plx)
ha = {0,0,0}
local a, b, c, d, e, s, z
local hr, _min, _time
local az, hz, nz, dz
if (RAn[3] < RAn[1]) then
RAn[3] = RAn[3] + 2 * M_PI
end
ha[1] = t0 - RAn[1] + (k * K1)
ha[3] = t0 - RAn[3] + (k * K1) + K1
ha[2] = (ha[3] + ha[1]) / 2 -- hour angle at half hour
Dec[2] = (Dec[3] + Dec[1]) / 2 -- declination at half hour
s = math.sin(DR * lat)
c = math.cos(DR * lat)
-- refraction + sun semidiameter at horizon + parallax correction
z = math.cos(DR * (90.567 - 41.685 / plx))
if (k <= 0) then -- first call of function
VHz[1] = s * math.sin(Dec[1]) + c * math.cos(Dec[1]) * math.cos(ha[1]) - z
end
VHz[3] = s * math.sin(Dec[3]) + c * math.cos(Dec[3]) * math.cos(ha[3]) - z
if (sgn(VHz[1]) == sgn(VHz[3])) then
return VHz[3] -- no event this hour
end
VHz[2] = s * math.sin(Dec[2]) + c * math.cos(Dec[2]) * math.cos(ha[2]) - z
a = 2 * VHz[3] - 4 * VHz[2] + 2 * VHz[1]
b = 4 * VHz[2] - 3 * VHz[1] - VHz[3]
d = b * b - 4 * a * VHz[1]
if (d < 0) then
return VHz[3] -- no event this hour
end
d = math.sqrt(d)
e = (-b + d) / (2 * a)
if ((e > 1) or (e < 0)) then
e = (-b - d) / (2 * a)
end
_time = k + e + 1 / 120 -- time of an event + round up
hr = math.floor(_time)
_min = math.floor((_time - hr) * 60)
hz = ha[1] + e * (ha[3] - ha[1]) -- azimuth of the moon at the event
nz = -math.cos(Dec[2]) * math.sin(hz)
dz = c * math.sin(Dec[2]) - s * math.cos(Dec[2]) * math.cos(hz)
az = math.atan2(nz, dz) / DR
if (az < 0) then
az = az + 360
end
if ((VHz[1] < 0) and (VHz[3] > 0)) then
if (hr <= 9) then
Rise_time[1] = '0'..hr
else
Rise_time[1] = hr
end
Rise_time[2] = _min
Rise_az = az
Moonrise = 1
end
if ((VHz[1] > 0) and (VHz[3] < 0)) then
if (hr <= 9) then
Set_time[1] = '0'..hr
else
Set_time[1] = hr
end
Set_time[2] = _min
Set_az = az
Moonset = 1
end
return VHz[3]
end
```

Hope this helps. But if you're using another skin, please let me know which one.