sun_moon.py: Allow DST adjustment to rise/set times.

master
Peter Hinch 2024-07-12 09:26:29 +01:00
rodzic 6f1366f8fc
commit d2e4f2408c
2 zmienionych plików z 11 dodań i 1 usunięć

Wyświetl plik

@ -184,6 +184,13 @@ Variants:
`time.time()`.
* 2 Return text of form hh:mm:ss (or --:--:--) being local time (`LT`).
If bit 2 of `variant` is set and a `dst` constructor arg has been passed, the
`dst` function will be applied to the result. This caters for the case where the
machine clock runs winter time and a dst-adjusted result is required. It should
be noted that applying dst adjustment to a time close to midnight can result in
rollover, i.e. a time > 24:00. Handling this case is the responsibility of the
application.
Example constructor invocations:
```python
r = RiSet() # UK near Manchester

Wyświetl plik

@ -319,11 +319,14 @@ class RiSet:
self._times[idx] = n
def _format(self, n, variant):
if (n is not None) and (variant & 4): # Machine clock set to UTC
variant &= 0x03
n = self.dst(n + self._t0) - self._t0
if variant == 0: # Default: secs since Midnight (local time)
return n
elif variant == 1: # Secs since epoch of MicroPython platform
return None if n is None else n + self._t0
# variant == 3
# variant == 2
if n is None:
return "--:--:--"
else: