OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 5 |
6 part of intl; | 6 part of intl; |
7 | 7 |
8 /** | 8 /** |
9 * A class for holding onto the data for a date so that it can be built | 9 * A class for holding onto the data for a date so that it can be built |
10 * up incrementally. | 10 * up incrementally. |
(...skipping 18 matching lines...) Expand all Loading... |
29 void setDay(x) { day = x; } | 29 void setDay(x) { day = x; } |
30 void setHour(x) { hour = x; } | 30 void setHour(x) { hour = x; } |
31 void setMinute(x) { minute = x; } | 31 void setMinute(x) { minute = x; } |
32 void setSecond(x) { second = x; } | 32 void setSecond(x) { second = x; } |
33 void setFractionalSecond(x) { fractionalSecond = x; } | 33 void setFractionalSecond(x) { fractionalSecond = x; } |
34 | 34 |
35 /** | 35 /** |
36 * Return a date built using our values. If no date portion is set, | 36 * Return a date built using our values. If no date portion is set, |
37 * use the "Epoch" of January 1, 1970. | 37 * use the "Epoch" of January 1, 1970. |
38 */ | 38 */ |
39 Date asDate() { | 39 DateTime asDate() { |
40 // TODO(alanknight): Validate the date, especially for things which | 40 // TODO(alanknight): Validate the date, especially for things which |
41 // can crash the VM, e.g. large month values. | 41 // can crash the VM, e.g. large month values. |
42 if (utc) { | 42 if (utc) { |
43 return new Date.utc( | 43 return new DateTime.utc( |
44 year, | 44 year, |
45 month, | 45 month, |
46 day, | 46 day, |
47 pm ? hour + 12 : hour, | 47 pm ? hour + 12 : hour, |
48 minute, | 48 minute, |
49 second, | 49 second, |
50 fractionalSecond); | 50 fractionalSecond); |
51 } else { | 51 } else { |
52 return new Date( | 52 return new DateTime( |
53 year, | 53 year, |
54 month, | 54 month, |
55 day, | 55 day, |
56 pm ? hour + 12 : hour, | 56 pm ? hour + 12 : hour, |
57 minute, | 57 minute, |
58 second, | 58 second, |
59 fractionalSecond); | 59 fractionalSecond); |
60 } | 60 } |
61 } | 61 } |
62 } | 62 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 * can see and then return the corresponding integer. Advance the stream. | 134 * can see and then return the corresponding integer. Advance the stream. |
135 */ | 135 */ |
136 var digitMatcher = new RegExp(r'\d+'); | 136 var digitMatcher = new RegExp(r'\d+'); |
137 int nextInteger() { | 137 int nextInteger() { |
138 var string = digitMatcher.stringMatch(rest()); | 138 var string = digitMatcher.stringMatch(rest()); |
139 if (string == null || string.isEmpty) return null; | 139 if (string == null || string.isEmpty) return null; |
140 read(string.length); | 140 read(string.length); |
141 return int.parse(string); | 141 return int.parse(string); |
142 } | 142 } |
143 } | 143 } |
OLD | NEW |