subtract method
Returns a copy of this with the duration
subtracted.
This function adds an exact number of microseconds unlike -. It may produce surprising results when added to a
ZonedDateTime
near a DST transition.
// 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, 13);
foo.subtract(Duration(days: 1)); // 2023-03-11T23:00-04:00
foo - Period(days: 1); // 2023-03-12T00:00-04:00
Implementation
@useResult ZonedDateTime subtract(Duration duration) => ZonedDateTime.fromEpochMicroseconds(
timezone,
epochMicroseconds - duration.inMicroseconds,
);