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

Side by Side Diff: corelib/src/date.dart

Issue 10534111: Revert "Refactor Date implementation in VM." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 | « no previous file | lib/compiler/implementation/lib/js_helper.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 *
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
12 * other words: [:value.abs() <= 8640000000000000:].
13 */ 9 */
14 interface Date extends Comparable, Hashable default DateImplementation { 10 interface Date extends Comparable, Hashable default DateImplementation {
15 // Weekday constants that are returned by [weekday] method: 11 // Weekday constants that are returned by [weekday] method:
16 static final int MON = 0; 12 static final int MON = 0;
17 static final int TUE = 1; 13 static final int TUE = 1;
18 static final int WED = 2; 14 static final int WED = 2;
19 static final int THU = 3; 15 static final int THU = 3;
20 static final int FRI = 4; 16 static final int FRI = 4;
21 static final int SAT = 5; 17 static final int SAT = 5;
22 static final int SUN = 6; 18 static final int SUN = 6;
23 static final int DAYS_IN_WEEK = 7; 19 static final int DAYS_IN_WEEK = 7;
24 20
25 // Month constants that are returned by the [month] getter. 21 // Month constants that are returned by the [month] getter.
26 static final int JAN = 1; 22 static final int JAN = 1;
27 static final int FEB = 2; 23 static final int FEB = 2;
28 static final int MAR = 3; 24 static final int MAR = 3;
29 static final int APR = 4; 25 static final int APR = 4;
30 static final int MAY = 5; 26 static final int MAY = 5;
31 static final int JUN = 6; 27 static final int JUN = 6;
32 static final int JUL = 7; 28 static final int JUL = 7;
33 static final int AUG = 8; 29 static final int AUG = 8;
34 static final int SEP = 9; 30 static final int SEP = 9;
35 static final int OCT = 10; 31 static final int OCT = 10;
36 static final int NOV = 11; 32 static final int NOV = 11;
37 static final int DEC = 12; 33 static final int DEC = 12;
38 34
39 /** 35 /**
40 * Constructs a [Date] instance based on the individual parts. The date is 36 * Constructs a [Date] instance based on the individual parts. The date is
41 * in the local time zone if [isUtc] is false. 37 * in the local time-zone if [isUtc] is false.
42 */ 38 */
43 // TODO(floitsch): the spec allows default values in interfaces, but our 39 // TODO(floitsch): the spec allows default values in interfaces, but our
44 // tools don't yet. Eventually we want to have default values here. 40 // tools don't yet. Eventually we want to have default values here.
45 Date(int year, 41 Date(int year,
46 [int month, 42 [int month,
47 int day, 43 int day,
48 int hours, 44 int hours,
49 int minutes, 45 int minutes,
50 int seconds, 46 int seconds,
51 int milliseconds, 47 int milliseconds,
52 bool isUtc]); 48 bool isUtc]);
53 49
54 /** 50 /**
55 * Constructs a new [Date] instance with current date time value in the 51 * Constructs a new [Date] instance with current date time value in the
56 * local time zone. 52 * local time zone.
57 */ 53 */
58 Date.now(); 54 Date.now();
59 55
60 /** 56 /**
61 * Constructs a new [Date] instance based on [formattedString]. 57 * Constructs a new [Date] instance based on [formattedString].
62 */ 58 */
63 Date.fromString(String formattedString); 59 Date.fromString(String formattedString);
64 60
65 /** 61 /**
66 * Constructs a new [Date] instance with the given [value]. If [isUtc] is 62 * Constructs a new [Date] instance with the given [value]. If [isUtc] is
67 * false then the date is in the local time zone. 63 * false then the date is in the local time-zone.
68 * 64 *
69 * The constructed [Date] represents 1970-01-01T00:00:00Z + [value]ms in 65 * The constructed [Date] represents 1970-01-01T00:00:00Z + [value]ms in
70 * the given time zone (local or UTC). 66 * the given time-zone (local or UTC).
71 */ 67 */
72 // TODO(floitsch): the spec allows default values in interfaces, but our 68 // TODO(floitsch): the spec allows default values in interfaces, but our
73 // tools don't yet. Eventually we want to have default values here. 69 // tools don't yet. Eventually we want to have default values here.
74 Date.fromEpoch(int value, [bool isUtc]); 70 Date.fromEpoch(int value, [bool isUtc]);
75 71
76 /** 72 /**
77 * Returns true if [this] occurs at the same time as [other]. The 73 * Returns true if [this] occurs at the same time as [other]. The
78 * comparison is independent of whether the time is utc or in the local 74 * comparison is independent of whether the time is utc or in the local
79 * time zone. 75 * time zone.
80 */ 76 */
(...skipping 16 matching lines...) Expand all
97 bool operator >(Date other); 93 bool operator >(Date other);
98 /** 94 /**
99 * Returns true if [this] occurs at the same time or after [other]. The 95 * Returns true if [this] occurs at the same time or after [other]. The
100 * comparison is independent of whether the time is utc or in the local 96 * comparison is independent of whether the time is utc or in the local
101 * time zone. 97 * time zone.
102 */ 98 */
103 bool operator >=(Date other); 99 bool operator >=(Date other);
104 100
105 101
106 /** 102 /**
107 * Returns [this] in the local time zone. Returns itself if it is already in 103 * Returns [this] in the local time-zone. Returns itself if it is already in
108 * the local time zone. Otherwise, this method is equivalent to 104 * the local time zone. Otherwise, this method is equivalent to
109 * [:new Date.fromEpoch(this.value, isUtc: false):]. 105 * [:new Date.fromEpoch(this.value, isUtc: false):].
110 */ 106 */
111 Date toLocal(); 107 Date toLocal();
112 108
113 /** 109 /**
114 * Returns [this] in UTC. Returns itself if it is already in UTC. Otherwise, 110 * Returns [this] in UTC. Returns itself if it is already in UTC. Otherwise,
115 * this method is equivalent to 111 * this method is equivalent to
116 * [:new Date.fromEpoch(this.value, isUtc: true):]. 112 * [:new Date.fromEpoch(this.value, isUtc: true):].
117 */ 113 */
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 /** 196 /**
201 * Returns a new [Date] with the [duration] subtracted from this instance. 197 * Returns a new [Date] with the [duration] subtracted from this instance.
202 */ 198 */
203 Date subtract(Duration duration); 199 Date subtract(Duration duration);
204 200
205 /** 201 /**
206 * Returns a [Duration] with the difference of [:this:] and [other]. 202 * Returns a [Duration] with the difference of [:this:] and [other].
207 */ 203 */
208 Duration difference(Date other); 204 Duration difference(Date other);
209 } 205 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/lib/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698