Skip to content

Commit

Permalink
uzsu: fix and improve perday interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
onkelandy committed Dec 21, 2024
1 parent 4089b11 commit f2c5ee5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions uzsu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1049,14 +1049,15 @@ def _get_time(self, entry, timescan, item=None, entryindex=None, caller=None):
if 'sun' in time and 'series' not in time:
next = self._sun(datetime.combine(today, datetime.min.time()).replace(tzinfo=self._timezone), time, timescan)
cond_future = next > datetime.now(self._timezone)
cond_istoday = next.date() == datetime.now().date()
if cond_future:
self.logger.debug(f'{item}: Result parsing time today (sun) {time}: {next}')
if entryindex is not None:
self._update_suncalc(item, entry, entryindex, next.strftime("%H:%M"))
else:
if caller != "dry_run" and not self._items[item]['interpolation'].get('perday'):
if caller != "dry_run" and (not self._items[item]['interpolation'].get('perday') or cond_istoday):
self._itpl[item][next.timestamp() * 1000.0] = value
self.logger.debug(f'{item}: Include previous today (sun): {next}, value {value} for interpolation.')
self.logger.debug(f'{item}: Include previous today (sun): {next}, value {value} for interpolation.')
if entryindex is not None:
self._update_suncalc(item, entry, entryindex, next.strftime("%H:%M"))
next = self._sun(datetime.combine(tomorrow, datetime.min.time()).replace(
Expand All @@ -1074,8 +1075,10 @@ def _get_time(self, entry, timescan, item=None, entryindex=None, caller=None):
next = self._series_get_time(entry, timescan)
if next is None:
return None, None, False
if caller != "dry_run":
cond_istoday = next.date() == datetime.now().date()
if caller != "dry_run" and (not self._items[item]['interpolation'].get('perday') or cond_istoday):
self._itpl[item][next.timestamp() * 1000.0] = value
self.logger.debug(f'{item}: Include {timescan} of series: {next} for interpolation.')
rstr = str(entry['rrule']).replace('\n', ';')
self.logger.debug(f'{item}: Looking for {timescan} series-related time. Found rrule: {rstr} '
f'with start-time {entry["series"]["timeSeriesMin"]}. Next: {next}')
Expand Down

0 comments on commit f2c5ee5

Please sign in to comment.