OLD | NEW |
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 // TODO(jmesserly): the native class should be the real JS Date. | 5 // TODO(jmesserly): the native class should be the real JS Date. |
6 // TODO(jimhug): Making the date value non-lazy might be a good path there. | 6 // TODO(jimhug): Making the date value non-lazy might be a good path there. |
7 class DateImplementation implements Date { | 7 class DateImplementation implements Date { |
8 final int value; | 8 final int value; |
9 final TimeZoneImplementation timeZone; | 9 final TimeZone timeZone; |
10 | 10 |
11 factory DateImplementation(int years, | 11 factory DateImplementation(int years, |
12 int month, | 12 int month, |
13 int day, | 13 int day, |
14 int hours, | 14 int hours, |
15 int minutes, | 15 int minutes, |
16 int seconds, | 16 int seconds, |
17 int milliseconds) { | 17 int milliseconds) { |
18 return new DateImplementation.withTimeZone( | 18 return new DateImplementation.withTimeZone( |
19 years, month, day, | 19 years, month, day, |
20 hours, minutes, seconds, milliseconds, | 20 hours, minutes, seconds, milliseconds, |
21 new TimeZoneImplementation.local()); | 21 new TimeZoneImplementation.local()); |
22 } | 22 } |
23 | 23 |
24 DateImplementation.withTimeZone(int years, | 24 DateImplementation.withTimeZone(int years, |
25 int month, | 25 int month, |
26 int day, | 26 int day, |
27 int hours, | 27 int hours, |
28 int minutes, | 28 int minutes, |
29 int seconds, | 29 int seconds, |
30 int milliseconds, | 30 int milliseconds, |
31 TimeZoneImplementation timeZone) | 31 TimeZone timeZone) |
32 : this.timeZone = timeZone, | 32 : this.timeZone = timeZone, |
33 value = _valueFromDecomposed(years, month, day, | 33 value = _valueFromDecomposed(years, month, day, |
34 hours, minutes, seconds, milliseconds, | 34 hours, minutes, seconds, milliseconds, |
35 timeZone.isUtc) { | 35 timeZone.isUtc) { |
36 if (value === null) throw new IllegalArgumentException(); | 36 if (value === null) throw new IllegalArgumentException(); |
37 _asJs(); | 37 _asJs(); |
38 } | 38 } |
39 | 39 |
40 DateImplementation.now() | 40 DateImplementation.now() |
41 : timeZone = new TimeZone.local(), | 41 : timeZone = new TimeZone.local(), |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 return isUtc == other.isUtc; | 281 return isUtc == other.isUtc; |
282 } | 282 } |
283 | 283 |
284 String toString() { | 284 String toString() { |
285 if (isUtc) return "TimeZone (UTC)"; | 285 if (isUtc) return "TimeZone (UTC)"; |
286 return "TimeZone (Local)"; | 286 return "TimeZone (Local)"; |
287 } | 287 } |
288 | 288 |
289 final bool isUtc; | 289 final bool isUtc; |
290 } | 290 } |
OLD | NEW |