subtract method

JDate subtract(
  1. Duration duration
)

Returns a new JDate instance with duration subtracted from this.

JDate today = new JDate.now();
JDate fiftyDaysAgo = today.subtract(new Duration(days: 50));

Notice that the duration being subtracted is actually 50 * 24 * 60 * 60 seconds. If the resulting JDate has a different daylight saving offset than this, then the result won't have the same time-of-day as this, and may not even hit the calendar date 50 days earlier.

Be careful when working with dates in local time.

Implementation

JDate subtract(Duration duration) => isJs
    ? JDate.fromMillisecondsSinceEpoch(
        _millisecondsSinceEpoch - duration.inMilliseconds)
    : JDate.fromMicrosecondsSinceEpoch(
        _microsecondsSinceEpoch - duration.inMicroseconds);