Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2785)

Unified Diff: tool/input_sdk/patch/core_patch.dart

Issue 1952133007: Update date_time. (Closed) Base URL: https://github.com/dart-lang/dev_compiler@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tool/input_sdk/lib/core/date_time.dart ('k') | tool/sdk_expected_errors.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tool/input_sdk/patch/core_patch.dart
diff --git a/tool/input_sdk/patch/core_patch.dart b/tool/input_sdk/patch/core_patch.dart
index e3f51f51302051fd5b76cce87167b8d043e75387..94b58883b57e997a7ab8cc0e627a8d9ac6c8c680 100644
--- a/tool/input_sdk/patch/core_patch.dart
+++ b/tool/input_sdk/patch/core_patch.dart
@@ -151,6 +151,18 @@ class Error {
@patch
class DateTime {
@patch
+ DateTime.fromMillisecondsSinceEpoch(int millisecondsSinceEpoch,
+ {bool isUtc: false})
+ : this._withValue(millisecondsSinceEpoch, isUtc: isUtc);
+
+ @patch
+ DateTime.fromMicrosecondsSinceEpoch(int microsecondsSinceEpoch,
+ {bool isUtc: false})
+ : this._withValue(
+ _microsecondInRoundedMilliseconds(microsecondsSinceEpoch),
+ isUtc: isUtc);
+
+ @patch
DateTime._internal(int year,
int month,
int day,
@@ -158,24 +170,38 @@ class DateTime {
int minute,
int second,
int millisecond,
+ int microsecond,
bool isUtc)
// checkBool is manually inlined here because dart2js doesn't inline it
// and [isUtc] is usually a constant.
- : this.isUtc = isUtc is bool ? isUtc : throw new ArgumentError(isUtc),
- millisecondsSinceEpoch = checkInt(Primitives.valueFromDecomposedDate(
- year, month, day, hour, minute, second, millisecond, isUtc));
+ : this.isUtc = isUtc is bool
+ ? isUtc
+ : throw new ArgumentError.value(isUtc, 'isUtc'),
+ _value = checkInt(Primitives.valueFromDecomposedDate(
+ year, month, day, hour, minute, second,
+ millisecond + _microsecondInRoundedMilliseconds(microsecond),
+ isUtc));
@patch
DateTime._now()
: isUtc = false,
- millisecondsSinceEpoch = Primitives.dateNow();
+ _value = Primitives.dateNow();
+
+ /// Rounds the given [microsecond] to the nearest milliseconds value.
+ ///
+ /// For example, invoked with argument `2600` returns `3`.
+ static int _microsecondInRoundedMilliseconds(int microsecond) {
+ return (microsecond / 1000).round();
+ }
@patch
- static int _brokenDownDateToMillisecondsSinceEpoch(
+ static int _brokenDownDateToValue(
int year, int month, int day, int hour, int minute, int second,
- int millisecond, bool isUtc) {
+ int millisecond, int microsecond, bool isUtc) {
return Primitives.valueFromDecomposedDate(
- year, month, day, hour, minute, second, millisecond, isUtc);
+ year, month, day, hour, minute, second,
+ millisecond + _microsecondInRoundedMilliseconds(microsecond),
+ isUtc);
}
@patch
@@ -191,6 +217,29 @@ class DateTime {
}
@patch
+ DateTime add(Duration duration) {
+ return new DateTime._withValue(
+ _value + duration.inMilliseconds, isUtc: isUtc);
+ }
+
+ @patch
+ DateTime subtract(Duration duration) {
+ return new DateTime._withValue(
+ _value - duration.inMilliseconds, isUtc: isUtc);
+ }
+
+ @patch
+ Duration difference(DateTime other) {
+ return new Duration(milliseconds: _value - other._value);
+ }
+
+ @patch
+ int get millisecondsSinceEpoch => _value;
+
+ @patch
+ int get microsecondsSinceEpoch => _value * 1000;
+
+ @patch
int get year => Primitives.getYear(this);
@patch
@@ -212,6 +261,9 @@ class DateTime {
int get millisecond => Primitives.getMilliseconds(this);
@patch
+ int get microsecond => 0;
+
+ @patch
int get weekday => Primitives.getWeekday(this);
}
@@ -282,6 +334,9 @@ class Map<K, V> {
factory Map.unmodifiable(Map other) {
return new UnmodifiableMapView<K, V>(new Map<K, V>.from(other));
}
+
+ @patch
+ factory Map() = JsLinkedHashMap<K, V>.es6;
}
@patch
« no previous file with comments | « tool/input_sdk/lib/core/date_time.dart ('k') | tool/sdk_expected_errors.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698