DateTime other
) Returns a Duration with the difference between this
and other
.
DateTime berlinWallFell = new DateTime(1989, DateTime.NOVEMBER, 9);
DateTime dDay = new DateTime(1944, DateTime.JUNE, 6);
Duration difference = berlinWallFell.difference(dDay);
assert(difference.inDays == 16592);
Source
/**
* Returns a [Duration] with the difference between [this] and [other].
*
* DateTime berlinWallFell = new DateTime(1989, DateTime.NOVEMBER, 9);
* DateTime dDay = new DateTime(1944, DateTime.JUNE, 6);
*
* Duration difference = berlinWallFell.difference(dDay);
* assert(difference.inDays == 16592);
*/
Duration difference(DateTime other) {
int ms = millisecondsSinceEpoch;
int otherMs = other.millisecondsSinceEpoch;
return new Duration(milliseconds: ms - otherMs);
}