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 part of dart.core; | 5 part of dart.core; |
6 | 6 |
7 /** | 7 /** |
8 * Deprecated class. Please use [DateTime] instead. | |
9 */ | |
10 @deprecated | |
11 abstract class Date implements Comparable<Date> { | |
12 // Weekday constants that are returned by [weekday] method: | |
13 static const int MON = 1; | |
14 static const int TUE = 2; | |
15 static const int WED = 3; | |
16 static const int THU = 4; | |
17 static const int FRI = 5; | |
18 static const int SAT = 6; | |
19 static const int SUN = 7; | |
20 static const int DAYS_IN_WEEK = 7; | |
21 | |
22 // Month constants that are returned by the [month] getter. | |
23 static const int JAN = 1; | |
24 static const int FEB = 2; | |
25 static const int MAR = 3; | |
26 static const int APR = 4; | |
27 static const int MAY = 5; | |
28 static const int JUN = 6; | |
29 static const int JUL = 7; | |
30 static const int AUG = 8; | |
31 static const int SEP = 9; | |
32 static const int OCT = 10; | |
33 static const int NOV = 11; | |
34 static const int DEC = 12; | |
35 | |
36 factory Date(int year, | |
37 [int month = 1, | |
38 int day = 1, | |
39 int hour = 0, | |
40 int minute = 0, | |
41 int second = 0, | |
42 int millisecond = 0]) { | |
43 return new DateTime(year, month, day, hour, minute, second, millisecond); | |
44 } | |
45 | |
46 factory Date.utc(int year, | |
47 [int month = 1, | |
48 int day = 1, | |
49 int hour = 0, | |
50 int minute = 0, | |
51 int second = 0, | |
52 int millisecond = 0]) { | |
53 return | |
54 new DateTime.utc(year, month, day, hour, minute, second, millisecond); | |
55 } | |
56 | |
57 factory Date.now() => new DateTime.now(); | |
58 | |
59 factory Date.fromString(String formattedString) | |
60 => DateTime.parse(formattedString); | |
61 | |
62 factory Date.fromMillisecondsSinceEpoch(int millisecondsSinceEpoch, | |
63 {bool isUtc: false}) { | |
64 return new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch, | |
65 isUtc: isUtc); | |
66 } | |
67 | |
68 bool operator ==(DateTime other); | |
69 bool operator <(DateTime other); | |
70 bool operator <=(DateTime other); | |
71 bool operator >(DateTime other); | |
72 bool operator >=(DateTime other); | |
73 | |
74 | |
75 DateTime toLocal(); | |
76 DateTime toUtc(); | |
77 | |
78 String get timeZoneName; | |
79 Duration get timeZoneOffset; | |
80 | |
81 int get year; | |
82 int get month; | |
83 int get day; | |
84 int get hour; | |
85 int get minute; | |
86 int get second; | |
87 int get millisecond; | |
88 | |
89 int get weekday; | |
90 | |
91 int get millisecondsSinceEpoch; | |
92 | |
93 bool get isUtc; | |
94 | |
95 String toString(); | |
96 | |
97 DateTime add(Duration duration); | |
98 DateTime subtract(Duration duration); | |
99 Duration difference(DateTime other); | |
100 } | |
101 | |
102 /** | |
103 * A DateTime object represents a point in time. | 8 * A DateTime object represents a point in time. |
104 * | 9 * |
105 * 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 |
106 * 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 |
107 * other words: [:millisecondsSinceEpoch.abs() <= 8640000000000000:]. | 12 * other words: [:millisecondsSinceEpoch.abs() <= 8640000000000000:]. |
108 * | 13 * |
109 * Also see [Stopwatch] for means to measure time-spans. | 14 * Also see [Stopwatch] for means to measure time-spans. |
110 */ | 15 */ |
111 class DateTime implements Date { | 16 class DateTime { |
112 // Weekday constants that are returned by [weekday] method: | 17 // Weekday constants that are returned by [weekday] method: |
113 static const int MON = 1; | 18 static const int MON = 1; |
114 static const int TUE = 2; | 19 static const int TUE = 2; |
115 static const int WED = 3; | 20 static const int WED = 3; |
116 static const int THU = 4; | 21 static const int THU = 4; |
117 static const int FRI = 5; | 22 static const int FRI = 5; |
118 static const int SAT = 6; | 23 static const int SAT = 6; |
119 static const int SUN = 7; | 24 static const int SUN = 7; |
120 static const int DAYS_IN_WEEK = 7; | 25 static const int DAYS_IN_WEEK = 7; |
121 | 26 |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 * Returns the millisecond into the second [0...999]. | 412 * Returns the millisecond into the second [0...999]. |
508 */ | 413 */ |
509 external int get millisecond; | 414 external int get millisecond; |
510 | 415 |
511 /** | 416 /** |
512 * Returns the week day [MON..SUN]. In accordance with ISO 8601 | 417 * Returns the week day [MON..SUN]. In accordance with ISO 8601 |
513 * a week starts with Monday which has the value 1. | 418 * a week starts with Monday which has the value 1. |
514 */ | 419 */ |
515 external int get weekday; | 420 external int get weekday; |
516 } | 421 } |
OLD | NEW |