operator - method

Expression<DateTime> operator -(
  1. Duration duration
)

Subtracts duration from this date.

Note that the curation is subtracted as a value in seconds. Thus, subtracting a Duration(days: 1) will not necessary yield the same time yesterday in all cases (due to daylight saving time switches). To change the value in terms of calendar units, see modify.

Implementation

Expression<DateTime> operator -(Duration duration) {
  return _DependingOnDateTimeExpression(
    // Date times are integers (unix timestamps), so we can do arithmetic on
    // them directly.
    forTimestamps: BaseInfixOperator(
        this, '-', Variable<int>(duration.inSeconds),
        precedence: Precedence.plusMinus),
    forIsoString:
        modify(DateTimeModifier.seconds(-duration.inMilliseconds / 1000)),
  );
}