[beta] Make web `DateTime.difference` not assume platform implementation. Changes `other._value` to `other.millisecondsSinceEpoch`, which prevents crashing if provided with a different implementation of `DateTime`. Exposed by #50750. Bug: https://dartbug.com/50750 Cherry-pick: https://github.com/dart-lang/sdk/issues/50821 Change-Id: I1dfc0bb4e8a44ef0df432c9a916a6620691e0547 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277002 Commit-Queue: Lasse Nielsen <lrn@google.com> Reviewed-by: Nate Bosch <nbosch@google.com> Auto-Submit: Lasse Nielsen <lrn@google.com>
diff --git a/sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart b/sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart index 567e9f1..50ee91c 100644 --- a/sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart +++ b/sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart
@@ -451,7 +451,7 @@ @patch Duration difference(DateTime other) { - return Duration(milliseconds: _value - other._value); + return Duration(milliseconds: _value - other.millisecondsSinceEpoch); } @patch
diff --git a/sdk/lib/_internal/js_runtime/lib/core_patch.dart b/sdk/lib/_internal/js_runtime/lib/core_patch.dart index 396ab47..603aad8a 100644 --- a/sdk/lib/_internal/js_runtime/lib/core_patch.dart +++ b/sdk/lib/_internal/js_runtime/lib/core_patch.dart
@@ -345,7 +345,7 @@ @patch Duration difference(DateTime other) { - return new Duration(milliseconds: _value - other._value); + return new Duration(milliseconds: _value - other.millisecondsSinceEpoch); } @patch