Index: sdk/lib/core/date_time.dart |
diff --git a/sdk/lib/core/date_time.dart b/sdk/lib/core/date_time.dart |
index 28ece3fc8289e80cf2a9bd00f23375ff3ba7d5fb..e44e419ec522e2e394059f197928c1ab3f9c65a3 100644 |
--- a/sdk/lib/core/date_time.dart |
+++ b/sdk/lib/core/date_time.dart |
@@ -371,6 +371,38 @@ class DateTime implements Comparable { |
} |
/** |
+ * Replaces specific parts of a date or time while keeping the rest. |
+ * |
+ * Equivalent to createing a new `DateTime` using `new DateTime` |
+ * with the values specified as arguments to this method, and taking |
+ * the values of the this `DateTime` object for arguments that were omitted. |
+ * |
+ * # Example |
+ * |
+ * var dt = new DateTime(1969, 7, 20, 20, 18); |
+ * var ut = dt.replace(day: 21, hour: 17, minute: 54); |
+ * Expect.equals("1969-07-21T17:54:00.000", "$ut"); |
+ * |
+ */ |
+ DateTime replace({int year, |
+ int month, |
+ int day, |
+ int hour, |
+ int minute, |
+ int second, |
+ int millisecond, |
+ bool isUtc}) { |
+ return new DateTime._internal(year ?? this.year, |
+ month ?? this.month, |
+ day ?? this.day, |
+ hour ?? this.hour, |
+ minute ?? this.minute, |
+ second ?? this.second, |
+ millisecond ?? this.millisecond, |
+ isUtc ?? this.isUtc); |
+ } |
+ |
+ /** |
* Returns true if [other] is a [DateTime] at the same moment and in the |
* same time zone (UTC or local). |
* |