operator - method

  1. @useResult
ZonedDateTime operator -(
  1. Period period
)

Returns a copy of this with the period subtracted.

This function adds the conceptual units of time unlike subtract.

// DST occurs at 2023-03-12 02:00
// https://www.timeanddate.com/time/change/usa/detroit?year=2023

final foo = ZonedDateTime('America/Detroit', 2023, 3, 12);

foo - Period(days: 1);           // 2023-03-12T00:00-04:00[America/Detroit]
foo.subtract(Duration(days: 1)); // 2023-03-11T23:00-04:00[America/Detroit]

Implementation

@useResult ZonedDateTime operator - (Period period) => ZonedDateTime._convert(timezone, _native - period);