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

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

Issue 10411057: Deprecate use of timezones. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 | corelib/src/time_zone.dart » ('j') | frog/lib/date_implementation.dart » ('J')
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 interface Date extends Comparable, Hashable default DateImplementation { 10 interface Date extends Comparable, Hashable default DateImplementation {
(...skipping 15 matching lines...) Expand all
26 static final int MAY = 5; 26 static final int MAY = 5;
27 static final int JUN = 6; 27 static final int JUN = 6;
28 static final int JUL = 7; 28 static final int JUL = 7;
29 static final int AUG = 8; 29 static final int AUG = 8;
30 static final int SEP = 9; 30 static final int SEP = 9;
31 static final int OCT = 10; 31 static final int OCT = 10;
32 static final int NOV = 11; 32 static final int NOV = 11;
33 static final int DEC = 12; 33 static final int DEC = 12;
34 34
35 /** 35 /**
36 * Constructs a [Date] instance based on the individual parts, in the 36 * Constructs a [Date] instance based on the individual parts. The date is
37 * local time-zone. 37 * in the local time-zone if [isUtc] is false.
38 */ 38 */
39 // TODO(floitsch): the spec allows default values in interfaces, but our 39 // TODO(floitsch): the spec allows default values in interfaces, but our
40 // 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.
41 Date(int year, 41 Date(int year,
42 [int month, 42 [int month,
43 int day, 43 int day,
44 int hours, 44 int hours,
45 int minutes, 45 int minutes,
46 int seconds, 46 int seconds,
47 int milliseconds]); 47 int milliseconds,
48 bool isUtc]);
48 49
49 /** 50 /**
50 * Constructs a [Date] instance based on the individual parts. 51 * Constructs a [Date] instance based on the individual parts.
51 * [timeZone] may not be [:null:]. 52 * [timeZone] may not be [:null:].
53 *
54 * *DEPRECATED*
52 */ 55 */
53 Date.withTimeZone(int year, 56 Date.withTimeZone(int year,
54 int month, 57 int month,
55 int day, 58 int day,
56 int hours, 59 int hours,
57 int minutes, 60 int minutes,
58 int seconds, 61 int seconds,
59 int milliseconds, 62 int milliseconds,
60 TimeZone timeZone); 63 TimeZone timeZone);
61 64
62 /** 65 /**
63 * Constructs a new [Date] instance with current date time value. 66 * Constructs a new [Date] instance with current date time value.
64 * The [timeZone] of this instance is set to the local time-zone. 67 * The [timeZone] of this instance is set to the local time-zone.
65 */ 68 */
66 Date.now(); 69 Date.now();
67 70
68 /** 71 /**
69 * Constructs a new [Date] instance based on [formattedString]. 72 * Constructs a new [Date] instance based on [formattedString].
70 */ 73 */
71 Date.fromString(String formattedString); 74 Date.fromString(String formattedString);
72 75
73 /** 76 /**
74 * Constructs a new [Date] instance with the given time zone. The given 77 * Constructs a new [Date] instance with the given [value]. If [isUtc] is
75 * [timeZone] must not be [:null:]. 78 * false then the date is in the local time-zone.
76 *
77 * This constructor is the only one that doesn't need to be computations and
78 * which can therefore be [:const:].
79 * 79 *
80 * The constructed [Date] represents 1970-01-01T00:00:00Z + [value]ms in 80 * The constructed [Date] represents 1970-01-01T00:00:00Z + [value]ms in
81 * the given [timeZone]. 81 * the given [timeZone].
ngeoffray 2012/05/22 08:58:45 Update comment
floitsch 2012/05/22 14:50:38 Done.
82 */ 82 */
83 const Date.fromEpoch(int value, TimeZone timeZone); 83 Date.fromEpoch(int value, [bool isUtc]);
84 84
85 /** 85 /**
86 * Returns true if [this] occurs at the same time as [other]. The
87 * comparison is independent of the time zone the [Date] is in.
ngeoffray 2012/05/22 08:58:45 of whether the time is utc or in the local time zo
floitsch 2012/05/22 14:50:38 Done.
88 */
89 bool operator ==(Date other);
90 /**
86 * Returns true if [this] occurs before [other]. The comparison is independent 91 * Returns true if [this] occurs before [other]. The comparison is independent
87 * of the timezone the [Date] is in. 92 * of the time zone the [Date] is in.
88 */ 93 */
89 bool operator <(Date other); 94 bool operator <(Date other);
90 /** 95 /**
91 * Returns true if [this] occurs at the same time or before [other]. The 96 * Returns true if [this] occurs at the same time or before [other]. The
92 * comparison is independent of the timezone the [Date] is in. 97 * comparison is independent of the time zone the [Date] is in.
93 */ 98 */
94 bool operator <=(Date other); 99 bool operator <=(Date other);
95 /** 100 /**
96 * Returns true if [this] occurs after [other]. The comparison is independent 101 * Returns true if [this] occurs after [other]. The comparison is independent
97 * of the timezone the [Date] is in. 102 * of the time zone the [Date] is in.
98 */ 103 */
99 bool operator >(Date other); 104 bool operator >(Date other);
100 /** 105 /**
101 * Returns true if [this] occurs at the same time or after [other]. The 106 * Returns true if [this] occurs at the same time or after [other]. The
102 * comparison is independent of the timezone the [Date] is in. 107 * comparison is independent of the time zone the [Date] is in.
103 */ 108 */
104 bool operator >=(Date other); 109 bool operator >=(Date other);
105 110
111
112 /**
113 * Returns [this] in the local time-zone. Returns itself if it is already in
114 * the local time zone. Otherwise, this method is equvalent to
ngeoffray 2012/05/22 08:58:45 equivalent
floitsch 2012/05/22 14:50:38 Done.
115 * [:new Date.fromEpoch(this.value, isUtc: false):].
116 */
117 Date toLocal();
118
119 /**
120 * Returns [this] in UTC. Returns itself it is already in UTC. Otherwise, this
ngeoffray 2012/05/22 08:58:45 itself *if* it is
floitsch 2012/05/22 14:50:38 Done.
121 * method is equvalent to [:new Date.fromEpoch(this.value, isUtc: true):].
ngeoffray 2012/05/22 08:58:45 equivalent
floitsch 2012/05/22 14:50:38 Done.
122 */
123 Date toUtc();
124
106 /** 125 /**
107 * Returns a new [Date] in the given [targetTimeZone] time zone. The 126 * Returns a new [Date] in the given [targetTimeZone] time zone. The
108 * [value] of the new instance is equal to [:this.value:]. 127 * [value] of the new instance is equal to [:this.value:].
109 * 128 *
110 * This call is equivalent to 129 * This call is equivalent to
111 * [:new Date.fromEpoch(this.value, targetTimeZone):]. 130 * [:new Date.fromEpoch(this.value, targetTimeZone):].
131 *
132 * *DEPRECATED*
112 */ 133 */
113 Date changeTimeZone(TimeZone targetTimeZone); 134 Date changeTimeZone(TimeZone targetTimeZone);
114 135
115 /** 136 /**
116 * Returns the abbreviated time-zone name. 137 * Returns the abbreviated time-zone name.
117 * 138 *
118 * Examples: [:"CET":] or [:"CEST":]. 139 * Examples: [:"CET":] or [:"CEST":].
119 */ 140 */
120 String get timeZoneName(); 141 String get timeZoneName();
121 142
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 192
172 /** 193 /**
173 * Returns milliseconds from 1970-01-01T00:00:00Z (UTC). 194 * Returns milliseconds from 1970-01-01T00:00:00Z (UTC).
174 * 195 *
175 * Note that this value is independent of [timeZone]. 196 * Note that this value is independent of [timeZone].
176 */ 197 */
177 final int value; 198 final int value;
178 199
179 /** 200 /**
180 * Returns the timeZone of this instance. 201 * Returns the timeZone of this instance.
202 *
203 * *DEPRECATED*.
181 */ 204 */
182 final TimeZone timeZone; 205 final TimeZone timeZone;
183 206
184 /** 207 /**
185 * Returns true if this [Date] is set to local time.
186 */
187 bool isLocalTime();
188
189 /**
190 * Returns true if this [Date] is set to UTC time. 208 * Returns true if this [Date] is set to UTC time.
191 * This is equivalent to [:this.timeZone.isUtc():].
192 */ 209 */
193 bool isUtc(); 210 bool isUtc();
194 211
195 /** 212 /**
196 * Returns a human readable string for this instance. 213 * Returns a human readable string for this instance.
197 * The returned string is constructed for the [timeZone] of this instance. 214 * The returned string is constructed for the [timeZone] of this instance.
198 */ 215 */
199 String toString(); 216 String toString();
200 217
201 /** 218 /**
202 * Returns a new [Date] with the [duration] added to this instance. 219 * Returns a new [Date] with the [duration] added to this instance.
203 */ 220 */
204 Date add(Duration duration); 221 Date add(Duration duration);
205 222
206 /** 223 /**
207 * Returns a new [Date] with the [duration] subtracted from this instance. 224 * Returns a new [Date] with the [duration] subtracted from this instance.
208 */ 225 */
209 Date subtract(Duration duration); 226 Date subtract(Duration duration);
210 227
211 /** 228 /**
212 * Returns a [Duration] with the difference of [:this:] and [other]. 229 * Returns a [Duration] with the difference of [:this:] and [other].
213 */ 230 */
214 Duration difference(Date other); 231 Duration difference(Date other);
215 } 232 }
OLDNEW
« no previous file with comments | « no previous file | corelib/src/time_zone.dart » ('j') | frog/lib/date_implementation.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698