def correct_gps_week_crossovers(time_diff: float) -> float:
    """
    Repairs over and underflow of GPS time, that is, the time difference
    must account for beginning or end of week crossovers.

    The time difference (time_diff) is the difference between a given GNSS epoch time t and toc:
        time_diff = t - toc
    time_diff is used, for example, in the computation of the clock bias, given the navigation clock model

    According to section [20.3.3.3.3.1] of **REF[3]**

    Args:
        time_diff (float) : time difference to be fixed
    Return:
        float : fixed time difference
    """
    half_week = 302400

    if time_diff > half_week:
        time_diff = time_diff - 2 * half_week

    elif time_diff < -half_week:
        time_diff = time_diff + 2 * half_week

    return time_diff