def _extrapolate_constant(to_time, from_sample):
    """Extrapolate a power rating to an earlier or later time.

    This models a constant power rating before (or after)
    the `from_sample` input to the `to_time`.

    It returns a power sample, of the same class as the `from_sample`
    but at the time specified in `to_time`.
    """
    sample_class = from_sample.__class__
    watts = from_sample.watts
    extrapolated_sample = sample_class(watts=watts, moment=to_time)
    return extrapolated_sample