def sec_to_exposure_decimation(sec):
    """
    Convert seconds to exposure and decimation.

    The algorithm is limited since it multiplies decimation by 10 until the
    resulting exposure is less than 65_535. This is not perfect because it
    limits decimation to 10_000 (the next step would be 100_000 which is
    bigger then max decimation of 65_535).
    The max theoretical value is ~497 days. This algorithm is limited to
    ~75 days. If it is not enough for you feel free to improve it :-)

    (max theoretical = datetime.timedelta(seconds = 2**16 * 2**16 * 10E-3))
    """
    decimation = 1
    deci_millis = sec * 100
    while (2 ** 16 * decimation) < deci_millis:
        decimation *= 10
    exposure = round(deci_millis / decimation)
    return exposure, decimation