Skip to content

Commit 8ad7661

Browse files
lrhnCommit Queue
authored and
Commit Queue
committed
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 #58750. Bug: https://dartbug.com/50750 Change-Id: I1dfc0bb4e8a44ef0df432c9a916a6620691e0547 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276523 Reviewed-by: Stephen Adams <[email protected]> Reviewed-by: Nate Bosch <[email protected]> Commit-Queue: Stephen Adams <[email protected]>
1 parent bc8606c commit 8ad7661

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
@@ -436,7 +436,7 @@ class DateTime {
436436

437437
@patch
438438
Duration difference(DateTime other) {
439-
return Duration(milliseconds: _value - other._value);
439+
return Duration(milliseconds: _value - other.millisecondsSinceEpoch);
440440
}
441441

442442
@patch

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ class DateTime {
330330

331331
@patch
332332
Duration difference(DateTime other) {
333-
return new Duration(milliseconds: _value - other._value);
333+
return new Duration(milliseconds: _value - other.millisecondsSinceEpoch);
334334
}
335335

336336
@patch

0 commit comments

Comments
 (0)