dateDifference method

Duration dateDifference(
  1. DateTime? first,
  2. DateTime? second
)

Use this function instead of DateTime.difference!

We do this be because there is an issue in the dart js sdk see here: https://github.com/dart-lang/sdk/blob/main/sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart#L442 and here: https://github.com/srawlins/timezone/issues/57

Implementation

Duration dateDifference(DateTime? first, DateTime? second) => Duration(
    milliseconds: (first?.millisecondsSinceEpoch ?? 0) -
        (second?.millisecondsSinceEpoch ?? 0));