/*[deutsch]
<p>Bestimmt die Jahresdifferenz zwischen den angegebenen Quartalen. </p>

@param   q1  first quarter year
@param   q2  second quarter year
@return  year difference
326478
public static Years<CalendarUnit> between(CalendarQuarter q1, CalendarQuarter q2) {

        int delta = q2.getYear() - q1.getYear();

        if (delta > 0) {
            if (q2.getQuarter().compareTo(q1.getQuarter()) < 0) {
                delta--;
            }
        } else if (delta < 0) {
            if (q2.getQuarter().compareTo(q1.getQuarter()) > 0) {
                delta++;
            }
        }

        return Years.ofGregorian(delta);

    }
804171
public List<Period> _Combine( List<Period> periods1, List<Period> periods2 )
	{
		List<Period> result = new ArrayList<Period>();

		int count1 = periods1.size();
		int count2 = periods2.size();

		int i = 0;
		int j = 0;
		while( i < count1 && j < count2 )
		{
			if( periods1.get( i ).getFrom().compareTo( periods2.get( j ).from ) <= 0 )
			{
				result.add( periods1.get( i ) );
				i++;
			}
			else
			{
				result.add( periods2.get( j ) );
				j++;
			}
		}
		while( i < count1 )
		{
			result.add( periods1.get( i ) );
			i++;
		}
		while( j < count2 )
		{
			result.add( periods2.get( j ) );
			j++;
		}

		return result;
	}
1318570
public final void mul(Quaternion q1) {
		double x1, y1, w1; 

		w1 = this.w*q1.w - this.x*q1.x - this.y*q1.y - this.z*q1.z;
		x1 = this.w*q1.x + q1.w*this.x + this.y*q1.z - this.z*q1.y;
		y1 = this.w*q1.y + q1.w*this.y - this.x*q1.z + this.z*q1.x;
		this.z = this.w*q1.z + q1.w*this.z + this.x*q1.y - this.y*q1.x;
		this.w = w1;
		this.x = x1;
		this.y = y1;
	}
168814
public Quaternionf add(Quaternionfc q2) {
        x += q2.x();
        y += q2.y();
        z += q2.z();
        w += q2.w();
        return this;
    }
223285
static public Angle difference(Angle angle1, Angle angle2) {
        return new Angle(angle1.value - angle2.value);
    }
523569
public int getEraYear(final Calendar cal) {
        ArgUtils.notNull(cal, "cal");
        
        final Calendar startCal = Calendar.getInstance(TimeZone.getTimeZone("GMT-00:00"));
        startCal.setTime(startDate);
        
        final int diff = cal.get(Calendar.YEAR) - startCal.get(Calendar.YEAR) + 1;
        return diff;
        
    }
671700
public static Years<CalendarUnit> ofGregorian(int years) {

        return ((years == 0) ? ZERO : (years == 1) ? ONE : new Years<>(years, CalendarUnit.YEARS));

    }
1358792
long getYearDifference(long minuendInstant, long subtrahendInstant) {
        int minuendYear = getYear(minuendInstant);
        int subtrahendYear = getYear(subtrahendInstant);
    
        // Inlined remainder method to avoid duplicate calls to get.
        long minuendRem = minuendInstant - getYearMillis(minuendYear);
        long subtrahendRem = subtrahendInstant - getYearMillis(subtrahendYear);
    
        // Balance leap year differences on remainders.
        if (subtrahendRem >= FEB_29) {
            if (isLeapYear(subtrahendYear)) {
                if (!isLeapYear(minuendYear)) {
                    subtrahendRem -= DateTimeConstants.MILLIS_PER_DAY;
                }
            } else if (minuendRem >= FEB_29 && isLeapYear(minuendYear)) {
                minuendRem -= DateTimeConstants.MILLIS_PER_DAY;
            }
        }
    
        int difference = minuendYear - subtrahendYear;
        if (minuendRem < subtrahendRem) {
            difference--;
        }
        return difference;
    }
1279476
public static long subMonths(final String dateString1, final String dateString2) {

    Date date1 = getDateFromString(dateString1, DEFAULT_DATE_SIMPLE_PATTERN);
    Date date2 = getDateFromString(dateString2, DEFAULT_DATE_SIMPLE_PATTERN);
    return subMonths(date1, date2);
  }
896954
@SuppressWarnings("checkstyle:ReturnCount")
  public static int compareBuff(final DirectBuffer o1, final DirectBuffer o2) {
    requireNonNull(o1);
    requireNonNull(o2);
    if (o1.equals(o2)) {
      return 0;
    }
    final int minLength = Math.min(o1.capacity(), o2.capacity());
    final int minWords = minLength / Long.BYTES;

    for (int i = 0; i < minWords * Long.BYTES; i += Long.BYTES) {
      final long lw = o1.getLong(i, BIG_ENDIAN);
      final long rw = o2.getLong(i, BIG_ENDIAN);
      final int diff = Long.compareUnsigned(lw, rw);
      if (diff != 0) {
        return diff;
      }
    }

    for (int i = minWords * Long.BYTES; i < minLength; i++) {
      final int lw = Byte.toUnsignedInt(o1.getByte(i));
      final int rw = Byte.toUnsignedInt(o2.getByte(i));
      final int result = Integer.compareUnsigned(lw, rw);
      if (result != 0) {
        return result;
      }
    }

    return o1.capacity() - o2.capacity();
  }
1372544
public Quaterniond add(Quaterniondc q2) {
        x += q2.x();
        y += q2.y();
        z += q2.z();
        w += q2.w();
        return this;
    }
749189
public static int getNumberOfDays(Date first, Date second)
      {
          Calendar c = Calendar.getInstance();
          int result = 0;
          int compare = first.compareTo(second);
          if (compare > 0) return 0;
          if (compare == 0) return 1;

          c.setTime(first);
          int firstDay = c.get(Calendar.DAY_OF_YEAR);
          int firstYear = c.get(Calendar.YEAR);
          int firstDays = c.getActualMaximum(Calendar.DAY_OF_YEAR);

          c.setTime(second);
          int secondDay = c.get(Calendar.DAY_OF_YEAR);
          int secondYear = c.get(Calendar.YEAR);

          // if dates in the same year
          if (firstYear == secondYear)
          {
              result = secondDay-firstDay+1;
          }

          // different years
          else
          {
              // days from the first year
              result += firstDays - firstDay + 1;

              // add days from all years between the two dates years
              for (int i = firstYear+1; i< secondYear; i++)
              {
                  c.set(i,0,0);
                  result += c.getActualMaximum(Calendar.DAY_OF_YEAR);
              }

              // days from last year
              result += secondDay;
          }

          return result;
      }
66551
public static int RankCompare(Solution solution1, Solution solution2)
   {
      int rank1 = solution1.getRank();
      int rank2 = solution2.getRank();

      if (rank1 < rank2)
      {
         return -1;
      }
      else if (rank1 > rank2)
      {
         return 1;
      }
      else
      {
         return 0;
      }
   }
1303497
public static String subtractSeq(final String first, final String second) {
    return subtractSeq(first, second, DELIMITER);
  }
1292416
def get_t_factor(t1, t2):
    
    t_factor = None
    if t1 is not None and t2 is not None and t1 != t2:  
        dt = t2 - t1
        year = timedelta(days=365.25)
        t_factor = abs(dt.total_seconds() / year.total_seconds()) 
    return t_factor
800519
@SuppressWarnings({ "unchecked" })
	protected int compare(E k1, E k2) {
		if (comparator == null) {
			return ((Comparable) k1).compareTo(k2);
		}
		return comparator.compare(k1, k2);
	}
857300
public static Years<CalendarUnit> between(CalendarMonth m1, CalendarMonth m2) {

        int delta = m1.getYear() - m2.getYear();

        if (delta > 0) {
            if (m2.getMonth().compareTo(m1.getMonth()) < 0) {
                delta--;
            }
        } else if (delta < 0) {
            if (m2.getMonth().compareTo(m1.getMonth()) > 0) {
                delta++;
            }
        }

        return Years.ofGregorian(delta);

    }