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

Side by Side Diff: lib/core/date.dart

Issue 11090016: Change core lib, dart2js, and more for new optional parameters syntax (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Dart core library. 5 // Dart core library.
6 6
7 /** 7 /**
8 * Date is the public interface to a point in time. 8 * Date is the public interface to a point in time.
9 * 9 *
10 * It can represent time values that are at a distance of at most 10 * It can represent time values that are at a distance of at most
(...skipping 25 matching lines...) Expand all
36 static const int SEP = 9; 36 static const int SEP = 9;
37 static const int OCT = 10; 37 static const int OCT = 10;
38 static const int NOV = 11; 38 static const int NOV = 11;
39 static const int DEC = 12; 39 static const int DEC = 12;
40 40
41 /** 41 /**
42 * Constructs a [Date] instance based on the individual parts. The date is 42 * Constructs a [Date] instance based on the individual parts. The date is
43 * in the local time zone if [isUtc] is false. 43 * in the local time zone if [isUtc] is false.
44 * 44 *
45 * [month] and [day] are one-based. For example 45 * [month] and [day] are one-based. For example
46 * [:new Date(1938, 1, 10)] represents the 10th of January 1938. 46 * [:new Date(1938, month: 1, day: 10)] represents the 10th of January 1938.
47 */ 47 */
48 factory Date(int year, 48 factory Date(int year,
Lasse Reichstein Nielsen 2012/10/09 12:35:00 Man, you just hit on our bad consciences there. We
Lasse Reichstein Nielsen 2012/10/09 12:50:40 Using optional positional parameters will make isU
regis 2012/10/11 01:33:56 Done.
regis 2012/10/11 01:33:56 Done.
49 [int month = 1, 49 {int month: 1,
50 int day = 1, 50 int day: 1,
51 int hour = 0, 51 int hour: 0,
52 int minute = 0, 52 int minute: 0,
53 int second = 0, 53 int second: 0,
54 int millisecond = 0, 54 int millisecond: 0,
55 bool isUtc = false]) { 55 bool isUtc: false}) {
56 return new DateImplementation(year, month, day, 56 return new DateImplementation(year, month: month, day: day,
Lasse Reichstein Nielsen 2012/10/09 12:35:00 Modify to match requested change in DateImplementa
regis 2012/10/11 01:33:56 Done.
57 hour, minute, second, 57 hour: hour, minute: minute, second: second,
58 millisecond, isUtc); 58 millisecond: millisecond, isUtc: isUtc);
59 } 59 }
60 60
61 /** 61 /**
62 * Constructs a new [Date] instance with current date time value in the 62 * Constructs a new [Date] instance with current date time value in the
63 * local time zone. 63 * local time zone.
64 */ 64 */
65 factory Date.now() => new DateImplementation.now(); 65 factory Date.now() => new DateImplementation.now();
66 66
67 /** 67 /**
68 * Constructs a new [Date] instance based on [formattedString]. 68 * Constructs a new [Date] instance based on [formattedString].
69 */ 69 */
70 factory Date.fromString(String formattedString) 70 factory Date.fromString(String formattedString)
71 => new DateImplementation.fromString(formattedString); 71 => new DateImplementation.fromString(formattedString);
72 72
73 /** 73 /**
74 * Constructs a new [Date] instance with the given [millisecondsSinceEpoch]. 74 * Constructs a new [Date] instance with the given [millisecondsSinceEpoch].
75 * If [isUtc] is false then the date is in the local time zone. 75 * If [isUtc] is false then the date is in the local time zone.
76 * 76 *
77 * The constructed [Date] represents 77 * The constructed [Date] represents
78 * 1970-01-01T00:00:00Z + [millisecondsSinceEpoch]ms in the given 78 * 1970-01-01T00:00:00Z + [millisecondsSinceEpoch]ms in the given
79 * time zone (local or UTC). 79 * time zone (local or UTC).
80 */ 80 */
81 // TODO(floitsch): the spec allows default values in interfaces, but our 81 // TODO(floitsch): the spec allows default values in interfaces, but our
82 // tools don't yet. Eventually we want to have default values here. 82 // tools don't yet. Eventually we want to have default values here.
83 // TODO(lrn): Have two constructors instead of taking an optional bool. 83 // TODO(lrn): Have two constructors instead of taking an optional bool.
84 factory Date.fromMillisecondsSinceEpoch(int millisecondsSinceEpoch, 84 factory Date.fromMillisecondsSinceEpoch(int millisecondsSinceEpoch,
85 [bool isUtc = false]) { 85 {bool isUtc: false}) {
86 return new DateImplementation.fromMillisecondsSinceEpoch( 86 return new DateImplementation.fromMillisecondsSinceEpoch(
87 millisecondsSinceEpoch, isUtc); 87 millisecondsSinceEpoch, isUtc);
88 } 88 }
89 89
90 /** 90 /**
91 * Returns true if [this] occurs at the same time as [other]. The 91 * Returns true if [this] occurs at the same time as [other]. The
92 * comparison is independent of whether the time is utc or in the local 92 * comparison is independent of whether the time is utc or in the local
93 * time zone. 93 * time zone.
94 */ 94 */
95 bool operator ==(Date other); 95 bool operator ==(Date other);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 /** 216 /**
217 * Returns a new [Date] with the [duration] subtracted from this instance. 217 * Returns a new [Date] with the [duration] subtracted from this instance.
218 */ 218 */
219 Date subtract(Duration duration); 219 Date subtract(Duration duration);
220 220
221 /** 221 /**
222 * Returns a [Duration] with the difference of [:this:] and [other]. 222 * Returns a [Duration] with the difference of [:this:] and [other].
223 */ 223 */
224 Duration difference(Date other); 224 Duration difference(Date other);
225 } 225 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698