I'm not sure what a good source for the length of "dawn" and "twilight" is, given that they vary a bit depending on the time of year and the location.Mordasius wrote:I've been following this thread with interest and would like to throw a small firecracker in the air if I may. My question is why have a fixed gap between the end of night and sunrise and between sunset and the beginning of night?
These times are twilight, oft referred to as dawn and dusk, when the sun is below the horizon but there is still enough light to see. Such a lovely light that is favoured by photographers and artists alike owing to the absence of shadows. Why not make that little gap between night and day represent the twilight? Be it Civil, Nautical or Astonomical.
I have a skin that I did where I guesstimate it at 30 minutes, and that is probably close and a good rough amount, but it can vary from 22-48 minutes depending on the above.
Skin:
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
LocationCode=USVA0944
[MeasureTime]
Measure=Time
Format=%#I:%M:%S %p
[MeasureSun]
Measure=WebParser
URL=https://wxdata.weather.com/wxdata/weather/local/#LocationCode#
RegExp=(?siU).*<sunr>(.*)</sunr>.*<suns>(.*)</suns>
FinishAction=[!EnableMeasure Lua][!UpdateMeasure Lua][!ShowMeterGroup MyMeters]
[MeasureRise]
Measure=WebParser
URL=[MeasureSun]
StringIndex=1
[MeasureSet]
Measure=WebParser
URL=[MeasureSun]
StringIndex=2
[Lua]
Measure=Script
ScriptFile=#CURRENTPATH#SunRiseSet.lua
Disabled=1
[MeterBack]
Meter=Image
Group=MyMeters
W=350
H=85
SolidColor=47,47,47,255
Hidden=1
[MeterDayState]
Meter=String
Group=MyMeters
X=10
Y=10
FontSize=15
FontWeight=700
FontColor=255,255,255,255
AntiAlias=1
Hidden=1
Text=Good [Lua:dayStateString]
DynamicVariables=1
[MeterSunState]
Meter=String
Group=MyMeters
X=10
Y=5R
FontSize=11
FontWeight=400
FontColor=255,255,255,255
InlineSetting=Weight | 700
InlinePattern=currently (.*) at
AntiAlias=1
Hidden=1
Text=It is currently [Lua:sunStateString] at [MeasureTime]
DynamicVariables=1
[MeterChange]
Meter=String
Group=MyMeters
X=10
Y=5R
FontSize=11
FontWeight=400
FontColor=255,255,255,255
InlineSetting=Weight | 700
InlinePattern=(.*) is in
AntiAlias=1
Hidden=1
Text=[Lua:changeString][Lua:formatString]
DynamicVariables=1
Code: Select all
function Initialize()
measureRise = SKIN:GetMeasure('MeasureRise')
measureSet = SKIN:GetMeasure('MeasureSet')
end
function Update()
inSunrise = measureRise:GetStringValue()
inSunset = measureSet:GetStringValue()
NextChange(inSunrise, inSunset)
return changeString..formatString
end
function NextChange(inSunrise, inSunset)
currentTime = os.date('*t')
secondsSinceMidnight = os.time() - os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=0, min=0, sec=0})
secondsTilMidnight = os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=23, min=59, sec=59}) - os.time()
riseHour = string.match(inSunrise, '(.-):')
riseMinute = string.match(inSunrise, '.-:(%d%d)')
setHour = string.match(inSunset, '(.-):') + 12
setMinute = string.match(inSunset, '.-:(%d%d)')
if currentTime.hour >= 0 and currentTime.hour < 12 then
dayStateString = 'Morning'
elseif currentTime.hour >= 12 and currentTime.hour < 18 then
dayStateString = 'Afternoon'
else
dayStateString = 'Evening'
end
if os.time() >= os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=setHour, min=setMinute}) then
dayState = 'SunRiseTomorrow'
elseif os.time() <= os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=riseHour, min=riseMinute}) then
dayState = 'SunRiseToday'
else
dayState = 'SunSetToday'
end
if dayState == 'SunRiseTomorrow' then
secondsTilChange = secondsTilMidnight + (riseHour * 3600) + (riseMinute * 60)
end
if dayState == 'SunRiseToday' then
secondsTilChange = ((riseHour * 3600) + (riseMinute * 60)) - secondsSinceMidnight
end
if dayState == 'SunSetToday' then
secondsTilChange = os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=setHour, min=setMinute}) - os.time()
end
formatTable = ConvertSeconds(secondsTilChange)
formatString = formatTable.hours..' hours '..formatTable.mins..' minutes '..formatTable.secs..' seconds'
if dayState == 'SunSetToday' then
sunStateString = 'Daytime'
changeString = 'Sunset is in '
else
sunStateString = 'Nighttime'
changeString = 'Sunrise is in '
end
if os.time() >= os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=riseHour, min=riseMinute}) - 1800 and os.time() <= os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=riseHour, min=riseMinute}) + 1800 then
sunStateString = 'Dawn'
end
if os.time() >= os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=setHour, min=setMinute}) - 1800 and os.time() <= os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=setHour, min=setMinute}) + 1800 then
sunStateString = 'Twilight'
end
return formatString
end
function ConvertSeconds(secondsArg)
local daysDiff = math.floor(secondsArg / 86400)
local remainder = (secondsArg % 86400)
local hoursDiff = math.floor(remainder / 3600)
local remainder = (secondsArg % 3600)
local minsDiff = math.floor(remainder / 60)
local secsDiff = (remainder % 60)
local elapsedTable = {days=daysDiff, hours=hoursDiff, mins=minsDiff, secs=secsDiff}
return elapsedTable
end
Code: Select all
if os.time() >= os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=riseHour, min=riseMinute}) - 1800 and os.time() <= os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=riseHour, min=riseMinute}) + 1800 then
sunStateString = 'Dawn'
end
if os.time() >= os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=setHour, min=setMinute}) - 1800 and os.time() <= os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=setHour, min=setMinute}) + 1800 then
sunStateString = 'Twilight'
end