| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_DATEPARSER_H_ | 5 #ifndef V8_DATEPARSER_H_ |
| 6 #define V8_DATEPARSER_H_ | 6 #define V8_DATEPARSER_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/char-predicates.h" | 9 #include "src/char-predicates.h" |
| 10 #include "src/parsing/scanner.h" | 10 #include "src/parsing/scanner.h" |
| 11 | 11 |
| 12 namespace v8 { | 12 namespace v8 { |
| 13 namespace internal { | 13 namespace internal { |
| 14 | 14 |
| 15 class DateParser : public AllStatic { | 15 class DateParser : public AllStatic { |
| 16 public: | 16 public: |
| 17 // Parse the string as a date. If parsing succeeds, return true after | 17 // Parse the string as a date. If parsing succeeds, return true after |
| 18 // filling out the output array as follows (all integers are Smis): | 18 // filling out the output array as follows (all integers are Smis): |
| 19 // [0]: year | 19 // [0]: year |
| 20 // [1]: month (0 = Jan, 1 = Feb, ...) | 20 // [1]: month (0 = Jan, 1 = Feb, ...) |
| 21 // [2]: day | 21 // [2]: day |
| 22 // [3]: hour | 22 // [3]: hour |
| 23 // [4]: minute | 23 // [4]: minute |
| 24 // [5]: second | 24 // [5]: second |
| 25 // [6]: millisecond | 25 // [6]: millisecond |
| 26 // [7]: UTC offset in seconds, or null value if no timezone specified | 26 // [7]: UTC offset in seconds, or null value if no timezone specified |
| 27 // If parsing fails, return false (content of output array is not defined). | 27 // If parsing fails, return false (content of output array is not defined). |
| 28 template <typename Char> | 28 template <typename Char> |
| 29 static bool Parse(Vector<Char> str, FixedArray* output, UnicodeCache* cache); | 29 static bool Parse(Isolate* isolate, Vector<Char> str, FixedArray* output); |
| 30 | 30 |
| 31 enum { | 31 enum { |
| 32 YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, MILLISECOND, UTC_OFFSET, OUTPUT_SIZE | 32 YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, MILLISECOND, UTC_OFFSET, OUTPUT_SIZE |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 // Range testing | 36 // Range testing |
| 37 static inline bool Between(int x, int lo, int hi) { | 37 static inline bool Between(int x, int lo, int hi) { |
| 38 return static_cast<unsigned>(x - lo) <= static_cast<unsigned>(hi - lo); | 38 return static_cast<unsigned>(x - lo) <= static_cast<unsigned>(hi - lo); |
| 39 } | 39 } |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 static DateParser::DateToken ParseES5DateTime( | 361 static DateParser::DateToken ParseES5DateTime( |
| 362 DateStringTokenizer<Char>* scanner, DayComposer* day, TimeComposer* time, | 362 DateStringTokenizer<Char>* scanner, DayComposer* day, TimeComposer* time, |
| 363 TimeZoneComposer* tz); | 363 TimeZoneComposer* tz); |
| 364 }; | 364 }; |
| 365 | 365 |
| 366 | 366 |
| 367 } // namespace internal | 367 } // namespace internal |
| 368 } // namespace v8 | 368 } // namespace v8 |
| 369 | 369 |
| 370 #endif // V8_DATEPARSER_H_ | 370 #endif // V8_DATEPARSER_H_ |
| OLD | NEW |