operator + method

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

Adds a duration to this date.

Note that the curation is added as a value in seconds. Thus, adding a Duration(days: 1) will not necessary yield the same time tomorrow 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)),
  );
}