Skip to content

Commit d57a06a

Browse files
lrhnCommit Queue
authored and
Commit Queue
committed
[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: #50821 Change-Id: I1dfc0bb4e8a44ef0df432c9a916a6620691e0547 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277002 Commit-Queue: Lasse Nielsen <[email protected]> Reviewed-by: Nate Bosch <[email protected]> Auto-Submit: Lasse Nielsen <[email protected]>
1 parent 3fe146a commit d57a06a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ class DateTime {
451451

452452
@patch
453453
Duration difference(DateTime other) {
454-
return Duration(milliseconds: _value - other._value);
454+
return Duration(milliseconds: _value - other.millisecondsSinceEpoch);
455455
}
456456

457457
@patch

sdk/lib/_internal/js_runtime/lib/core_patch.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ class DateTime {
345345

346346
@patch
347347
Duration difference(DateTime other) {
348-
return new Duration(milliseconds: _value - other._value);
348+
return new Duration(milliseconds: _value - other.millisecondsSinceEpoch);
349349
}
350350

351351
@patch

0 commit comments

Comments
 (0)