class PackedLocalTime {

  public static int plusSeconds(int secondsToAdd, int packedTime) {
    if (secondsToAdd == 0) {
      return packedTime;
    }
    int hour = PackedLocalTime.getHour(packedTime);
    int minute = PackedLocalTime.getMinute(packedTime);
    int second = PackedLocalTime.getSecond(packedTime);
    int milli = PackedLocalTime.getMilliseconds(packedTime);

    int sofd = hour * SECONDS_PER_HOUR + minute * SECONDS_PER_MINUTE + second;
    int newSofd = ((secondsToAdd % SECONDS_PER_DAY) + sofd + SECONDS_PER_DAY) % SECONDS_PER_DAY;
    if (sofd == newSofd) {
      return packedTime;
    }
    int newHour = newSofd / SECONDS_PER_HOUR;
    int newMinute = (newSofd / SECONDS_PER_MINUTE) % MINUTES_PER_HOUR;
    int newSecond = newSofd % SECONDS_PER_MINUTE;
    return create(newHour, newMinute, newSecond, milli);
  }

}