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

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

Issue 10948009: Revert 12494. (Closed) Base URL: http://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 abstract class Date implements Comparable, Hashable { 16 interface Date extends Comparable, Hashable default DateImplementation {
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 factory Date(int year, 48 // TODO(floitsch): the spec allows default values in interfaces, but our
49 [int month = 1, 49 // tools don't yet. Eventually we want to have default values here.
50 int day = 1, 50 Date(int year,
51 int hour = 0, 51 [int month,
52 int minute = 0, 52 int day,
53 int second = 0, 53 int hour,
54 int millisecond = 0, 54 int minute,
55 bool isUtc = false]) { 55 int second,
56 return new DateImplementation(year, month, day, 56 int millisecond,
57 hour, minute, second, 57 bool isUtc]);
58 millisecond, isUtc);
59 }
60 58
61 /** 59 /**
62 * Constructs a new [Date] instance with current date time value in the 60 * Constructs a new [Date] instance with current date time value in the
63 * local time zone. 61 * local time zone.
64 */ 62 */
65 factory Date.now() => new DateImplementation.now(); 63 Date.now();
66 64
67 /** 65 /**
68 * Constructs a new [Date] instance based on [formattedString]. 66 * Constructs a new [Date] instance based on [formattedString].
69 */ 67 */
70 factory Date.fromString(String formattedString) 68 Date.fromString(String formattedString);
71 => new DateImplementation.fromString(formattedString);
72 69
73 /** 70 /**
74 * Constructs a new [Date] instance with the given [millisecondsSinceEpoch]. 71 * Constructs a new [Date] instance with the given [millisecondsSinceEpoch].
75 * If [isUtc] is false then the date is in the local time zone. 72 * If [isUtc] is false then the date is in the local time zone.
76 * 73 *
77 * The constructed [Date] represents 74 * The constructed [Date] represents
78 * 1970-01-01T00:00:00Z + [millisecondsSinceEpoch]ms in the given 75 * 1970-01-01T00:00:00Z + [millisecondsSinceEpoch]ms in the given
79 * time zone (local or UTC). 76 * time zone (local or UTC).
80 */ 77 */
81 // TODO(floitsch): the spec allows default values in interfaces, but our 78 // TODO(floitsch): the spec allows default values in interfaces, but our
82 // tools don't yet. Eventually we want to have default values here. 79 // tools don't yet. Eventually we want to have default values here.
83 // TODO(lrn): Have two constructors instead of taking an optional bool. 80 Date.fromMillisecondsSinceEpoch(int millisecondsSinceEpoch, [bool isUtc]);
84 factory Date.fromMillisecondsSinceEpoch(int millisecondsSinceEpoch,
85 [bool isUtc = false]) {
86 return new DateImplementation.fromMillisecondsSinceEpoch(
87 millisecondsSinceEpoch, isUtc);
88 }
89 81
90 /** 82 /**
91 * Returns true if [this] occurs at the same time as [other]. The 83 * 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 84 * comparison is independent of whether the time is utc or in the local
93 * time zone. 85 * time zone.
94 */ 86 */
95 bool operator ==(Date other); 87 bool operator ==(Date other);
96 /** 88 /**
97 * Returns true if [this] occurs before [other]. The comparison is independent 89 * Returns true if [this] occurs before [other]. The comparison is independent
98 * of whether the time is utc or in the local time zone. 90 * of whether the time is utc or in the local time zone.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 /** 208 /**
217 * Returns a new [Date] with the [duration] subtracted from this instance. 209 * Returns a new [Date] with the [duration] subtracted from this instance.
218 */ 210 */
219 Date subtract(Duration duration); 211 Date subtract(Duration duration);
220 212
221 /** 213 /**
222 * Returns a [Duration] with the difference of [:this:] and [other]. 214 * Returns a [Duration] with the difference of [:this:] and [other].
223 */ 215 */
224 Duration difference(Date other); 216 Duration difference(Date other);
225 } 217 }
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