def monotoniclocaltime(seconds=None):
    """monotoniclocaltime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,
                                  tm_sec,tm_wday,tm_yday,tm_isdst)

Convert seconds since the Epoch to a time tuple expressing monotonic
local time. Monotonicity is achieved by extending the day before the
end of DST with some extra hours (24, 25 etc) until after the switch."""

    if seconds is None:
        seconds = time.time()

    res = time.localtime(seconds)

    dayseconds = res.tm_sec + res.tm_min*60 + res.tm_hour*3600
    nextmidnight = time.localtime(seconds - dayseconds + 86400)

    if res.tm_isdst and not nextmidnight.tm_isdst:
        tl = list(time.localtime(seconds - 86400))  # same time yesterday
        tl[3] += 24                                 # plus 24h
        res = time.struct_time(tl)

    return res
monotoniclocaltime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,
                                  tm_sec,tm_wday,tm_yday,tm_isdst)

Convert seconds since the Epoch to a time tuple expressing monotonic
local time. Monotonicity is achieved by extending the day before the
end of DST with some extra hours (24, 25 etc) until after the switch.
recipes/Python/578270_Monotonic_local_time/recipe-578270.py