diff --git a/astronomy/README.md b/astronomy/README.md index 2922e3c..85746ad 100644 --- a/astronomy/README.md +++ b/astronomy/README.md @@ -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 diff --git a/astronomy/sun_moon.py b/astronomy/sun_moon.py index dfdf421..a092b28 100644 --- a/astronomy/sun_moon.py +++ b/astronomy/sun_moon.py @@ -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: