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

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

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