def _roll_negative_time_fields(year, month, day, hour, minute, second):
    """
    Fix date/time fields which have nonsense negative values for any field
    except for year by rolling the overall date/time value backwards, treating
    negative values as relative offsets of the next higher unit.

    For example minute=5, second=-63 becomes minute=3, second=57 (5 minutes
    less 63 seconds)

    This is very unsophisticated handling of negative values which we would
    ideally do with `dateutil.relativedelta` but cannot because that class does
    not support arbitrary dates, especially not negative years which is the
    only case where these nonsense values are likely to occur anyway.

    NOTE: To greatly simplify the logic we assume all months are 30 days long.
    """
    if second < 0:
        minute += int(second / 60.0)
        minute -= 1
        second %= 60
    if minute < 0:
        hour += int(minute / 60.0)
        hour -= 1
        minute %= 60
    if hour < 0:
        day += int(hour / 24.0)
        day -= 1
        hour %= 24
    if day < 0:
        month += int(day / 30.0)
        month -= 1
        day %= 30
    if month < 0:
        year += int(month / 12.0)
        year -= 1
        month %= 12
    return year, month, day, hour, minute, second
