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

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

Issue 10939030: Reapply conversion of most core interfaces to abstract classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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
« no previous file with comments | « lib/compiler/implementation/lib/coreimpl.dart ('k') | lib/core/duration.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 * 8,640,000,000,000,000ms (100,000,000 days) from epoch (1970-01-01 UTC). In 11 * 8,640,000,000,000,000ms (100,000,000 days) from epoch (1970-01-01 UTC). In
12 * other words: [:millisecondsSinceEpoch.abs() <= 8640000000000000:]. 12 * other words: [:millisecondsSinceEpoch.abs() <= 8640000000000000:].
13 * 13 *
14 * Also see [Stopwatch] for means to measure time-spans. 14 * Also see [Stopwatch] for means to measure time-spans.
15 */ 15 */
16 interface Date extends Comparable, Hashable default DateImplementation { 16 abstract class Date implements Comparable, Hashable {
17 // Weekday constants that are returned by [weekday] method: 17 // Weekday constants that are returned by [weekday] method:
18 static const int MON = 1; 18 static const int MON = 1;
19 static const int TUE = 2; 19 static const int TUE = 2;
20 static const int WED = 3; 20 static const int WED = 3;
21 static const int THU = 4; 21 static const int THU = 4;
22 static const int FRI = 5; 22 static const int FRI = 5;
23 static const int SAT = 6; 23 static const int SAT = 6;
24 static const int SUN = 7; 24 static const int SUN = 7;
25 static const int DAYS_IN_WEEK = 7; 25 static const int DAYS_IN_WEEK = 7;
26 26
(...skipping 11 matching lines...) Expand all
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, 1, 10)] represents the 10th of January 1938.
47 */ 47 */
48 // TODO(floitsch): the spec allows default values in interfaces, but our 48 factory Date(int year,
49 // tools don't yet. Eventually we want to have default values here. 49 [int month = 1,
50 Date(int year, 50 int day = 1,
51 [int month = 1, 51 int hour = 0,
52 int day = 1, 52 int minute = 0,
53 int hour = 0, 53 int second = 0,
54 int minute = 0, 54 int millisecond = 0,
55 int second = 0, 55 bool isUtc = false]) {
56 int millisecond = 0, 56 return new DateImplementation(year, month, day,
57 bool isUtc = false]); 57 hour, minute, second,
58 millisecond, isUtc);
59 }
58 60
59 /** 61 /**
60 * 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
61 * local time zone. 63 * local time zone.
62 */ 64 */
63 Date.now(); 65 factory Date.now() => new DateImplementation.now();
64 66
65 /** 67 /**
66 * Constructs a new [Date] instance based on [formattedString]. 68 * Constructs a new [Date] instance based on [formattedString].
67 */ 69 */
68 Date.fromString(String formattedString); 70 factory Date.fromString(String formattedString)
71 => new DateImplementation.fromString(formattedString);
69 72
70 /** 73 /**
71 * Constructs a new [Date] instance with the given [millisecondsSinceEpoch]. 74 * Constructs a new [Date] instance with the given [millisecondsSinceEpoch].
72 * 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.
73 * 76 *
74 * The constructed [Date] represents 77 * The constructed [Date] represents
75 * 1970-01-01T00:00:00Z + [millisecondsSinceEpoch]ms in the given 78 * 1970-01-01T00:00:00Z + [millisecondsSinceEpoch]ms in the given
76 * time zone (local or UTC). 79 * time zone (local or UTC).
77 */ 80 */
78 // TODO(floitsch): the spec allows default values in interfaces, but our 81 // TODO(floitsch): the spec allows default values in interfaces, but our
79 // 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.
80 Date.fromMillisecondsSinceEpoch(int millisecondsSinceEpoch, [bool isUtc]); 83 // TODO(lrn): Have two constructors instead of taking an optional bool.
84 factory Date.fromMillisecondsSinceEpoch(int millisecondsSinceEpoch,
85 [bool isUtc = false]) {
86 return new DateImplementation.fromMillisecondsSinceEpoch(
87 millisecondsSinceEpoch, isUtc);
88 }
81 89
82 /** 90 /**
83 * 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
84 * 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
85 * time zone. 93 * time zone.
86 */ 94 */
87 bool operator ==(Date other); 95 bool operator ==(Date other);
88 /** 96 /**
89 * Returns true if [this] occurs before [other]. The comparison is independent 97 * Returns true if [this] occurs before [other]. The comparison is independent
90 * of whether the time is utc or in the local time zone. 98 * of whether the time is utc or in the local time zone.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 /** 216 /**
209 * Returns a new [Date] with the [duration] subtracted from this instance. 217 * Returns a new [Date] with the [duration] subtracted from this instance.
210 */ 218 */
211 Date subtract(Duration duration); 219 Date subtract(Duration duration);
212 220
213 /** 221 /**
214 * Returns a [Duration] with the difference of [:this:] and [other]. 222 * Returns a [Duration] with the difference of [:this:] and [other].
215 */ 223 */
216 Duration difference(Date other); 224 Duration difference(Date other);
217 } 225 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/lib/coreimpl.dart ('k') | lib/core/duration.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698