operator - method
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
// Assume the current timezone is `America/Detroit`.
final foo = DateTime(2023, 3, 12);
foo - Period(days: 1); // 2023-03-12 00:00-04:00
foo.subtract(Duration(days: 1)); // 2023-03-11 23:00-04:00
Implementation
@useResult DateTime operator - (Period period) => copyWith(
year: year - period.years,
month: month - period.months,
day: day - period.days,
hour: hour - period.hours,
minute: minute - period.minutes,
second: second - period.seconds,
millisecond: millisecond - period.milliseconds,
microsecond: microsecond - period.microseconds,
);