RiseT Block - Minor 'Tweak' for Daylight Time Difference Near Solstice

Post Reply
User avatar
MonyMony
Forecaster
Forecaster
Posts: 192
Joined: Sun Aug 20, 2017 12:54 pm
Location: Elkton, Maryland, US
Station model: Davis Pro 2
Software: WeatherCat/Meteobridge
Contact:

RiseT Block - Minor 'Tweak' for Daylight Time Difference Near Solstice

Post by MonyMony » Tue Dec 17, 2019 2:25 am

Figured I would share this as I have noticed this issue for a while and it always would drive me crazy around this time of year. The RISET block when the days would near the solstice would show the daylight time difference as "0s" even though there was a difference between 'today' and the actual solstice.
Before Code Update
Before Code Update
Screen Shot 2019-12-16 at 9.08.08 PM.png (52.88 KiB) Viewed 4126 times
Finally spent time and spotted the issue. If you open up the riseBlock.php code and look at line 355 (in the convertDuration function), the line currently was set to this:

Code: Select all

else{
	return "0s";
That results in any time calculation under one minute to just list as 0s.

To revise this and show the actual difference when the calculation is under one minute, change Line 355 to this:

Code: Select all

else if($seconds<15){
	return "≈0 s";
}
else{
	return $seconds." s";
}
The result is now this:
After Code Update
After Code Update
Screen Shot 2019-12-16 at 9.19.26 PM.png (76.39 KiB) Viewed 4126 times
While I suppose it is possible this might introduce some odd behavior in rare situations, I cannot spot any potential ill-effects.

Note: I made a minor modification to the updated code to account for the calculations not being precise. I suspect this is why the code was originally setup to just show 0s in the first place. :o
Image

Post Reply