Fix problem with delta times.

Fixes issue #1009.
This commit is contained in:
Tom Keffer
2025-08-09 14:12:00 -07:00
parent 49def127b9
commit 153c74efa8
2 changed files with 8 additions and 5 deletions

View File

@@ -28,6 +28,9 @@ The utility and documentation have been changed to use `cur_in_temp` (one
'`r`'), making all types consistent. Fixes [Issue
#1006](https://github.com/weewx/weewx/issues/1006).
Fix a problem caused by an assumption that delta times are always in seconds.
Fixes issue [Issue #1009](https://github.com/weewx/weewx/issues/1009).
### 5.1.0 07/04/2024

View File

@@ -415,17 +415,17 @@ class AlmanacBinder:
def visible_change(self, days_ago=1):
"""Change in visibility of the heavenly body compared to 'days_ago'."""
# Visibility for today:
# Visibility for today, as a ValueTuple
today_visible = self.visible
# The time to compare to
then_time = self.almanac.time_ts - days_ago * 86400
# Get a new almanac, set up for the time back then
then_almanac = self.almanac(almanac_time=then_time)
# Find the visibility back then
# Find the visibility back then as a ValueTuple
then_visible = getattr(then_almanac, self.heavenly_body).visible
# Take the difference
diff = today_visible.raw - then_visible.raw
return weewx.units.ValueHelper(ValueTuple(diff, "second", "group_deltatime"),
# Take the difference, which will also be a ValueTuple
diff_vt = today_visible.value_t - then_visible.value_t
return weewx.units.ValueHelper(diff_vt,
context="hour",
formatter=self.almanac.formatter,
converter=self.almanac.converter)