Subtract one date from the other.

@param lhs a Date
@param rhs another Date
@return a Duration
483037
public static TimeDuration minus(final Date lhs, final Date rhs) {
        long milliseconds = lhs.getTime() - rhs.getTime();
        long days = milliseconds / (24 * 60 * 60 * 1000);
        milliseconds -= days * 24 * 60 * 60 * 1000;
        int hours = (int) (milliseconds / (60 * 60 * 1000));
        milliseconds -= hours * 60 * 60 * 1000;
        int minutes = (int) (milliseconds / (60 * 1000));
        milliseconds -= minutes * 60 * 1000;
        int seconds = (int) (milliseconds / 1000);
        milliseconds -= seconds * 1000;

        return new TimeDuration((int) days, hours, minutes, seconds, (int) milliseconds);
    }
1240817
@Override
  public int compareTo(@Nonnull TimeAndDimsPointer rhs)
  {
    long timestamp = getTimestamp();
    long rhsTimestamp = rhs.getTimestamp();
    int timestampDiff = Long.compare(timestamp, rhsTimestamp);
    if (timestampDiff != 0) {
      return timestampDiff;
    }
    for (int dimIndex = 0; dimIndex < dimensionSelectors.length; dimIndex++) {
      int dimDiff = dimensionSelectorComparators[dimIndex].compare(
          dimensionSelectors[dimIndex],
          rhs.dimensionSelectors[dimIndex]
      );
      if (dimDiff != 0) {
        return dimDiff;
      }
    }
    return 0;
  }
26903
public static BigDecimal subtract(final BigDecimal start, final BigDecimal... values) {
        BigDecimal total = start != null ? start : BigDecimal.ZERO;
        if (values != null) {
            for (final BigDecimal v : values) {
                total = doSubtract(total, v);
            }
        }
        return total;
    }
446092
public static <T extends Comparable<T>> T min(T lhs, T rhs) {
        return BinaryOperator.minBy(new ComparableComparator<T>()).apply(lhs, rhs);
    }
236102
public Timecode subtract(SampleCount samples)
	{
		final SampleCount mySamples = getSampleCount();
		final SampleCount result = mySamples.subtract(samples);

		return Timecode.getInstance(result, dropFrame);
	}
818896
public long toMilliseconds() {
        final Date now = new Date();
        return TimeCategory.minus(plus(now), now).toMilliseconds();
    }
571830
public static function subtractDay($ts = null, $num = 1)
	{
		return sfTime::subtract($ts, $num, sfTime::DAY);
	}
804848
public static StringExpression left(Expression<String> lhs, int rhs) {
        return left(lhs, ConstantImpl.create(rhs));
    }
1025048
public List<Formula> newLowerBound(int rhs) {
    this.result.reset();
    this.computeLBConstraint(this.result, rhs);
    return this.result.result();
  }
901932
public static double[] minusTimes(final double[] v1, final double[] v2, final double s2) {
    assert v1.length == v2.length : ERR_VEC_DIMENSIONS;
    final double[] sub = new double[v1.length];
    for(int i = 0; i < v1.length; i++) {
      sub[i] = v1[i] - v2[i] * s2;
    }
    return sub;
  }
997822
public static double durationSeconds(LocalDateTime start, LocalDateTime end)
   {
	   return Duration.between(start, end).getSeconds();
   }
237806
public CalendarMonth minus(Years<CalendarUnit> years) {

        if (years.isEmpty()) {
            return this;
        }

        return CalendarMonth.of(MathUtils.safeSubtract(this.year, years.getAmount()), this.month);

    }
271404
public static Date substractYearsFromDate(final Date date, final int substractYears)
	{
		final Calendar dateOnCalendar = Calendar.getInstance();
		dateOnCalendar.setTime(date);
		dateOnCalendar.add(Calendar.YEAR, substractYears * -1);
		return dateOnCalendar.getTime();
	}
438517
def -(other)
      case other
      when 0
        self
      when Duration
        Duration.new(
          seconds: @seconds - other.get(:seconds),
          months: @months - other.get(:months)
        )
      else
        raise ArgumentError, "Cannot subtract #{other.inspect} from Duration #{self}"
      end
    end
196834
public static function subtractWeek($ts = null, $num = 1)
	{
		return sfTime::subtract($ts, $num, sfTime::WEEK);
	}
628760
public static function subtractSecond($ts = null, $num = 1)
	{
		return sfTime::subtract($ts, $num, sfTime::SECOND);
	}
370378
public static void subtract(double[] array1, double[] array2) {
        assert (array1.length == array2.length);
        for (int i=0; i<array1.length; i++) {
            array1[i] -= array2[i];
        }
    }