OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 15 matching lines...) Expand all Loading... |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include "v8.h" | 28 #include "v8.h" |
29 | 29 |
30 #include "dateparser.h" | 30 #include "dateparser.h" |
31 | 31 |
32 namespace v8 { | 32 namespace v8 { |
33 namespace internal { | 33 namespace internal { |
34 | 34 |
35 bool DateParser::DayComposer::Write(FixedArray* output) { | 35 bool DateParser::DayComposer::Write(FixedArray* output) { |
36 // Set year to 0 by default. | 36 if (index_ < 1) return false; |
37 if (index_ < 1) { | 37 // Day and month defaults to 1. |
38 comp_[index_++] = 1; | 38 while (index_ < kSize) { |
39 } | 39 comp_[index_++] = 1; |
40 | 40 } |
41 // Day and month defaults to 1. | |
42 while (index_ < kSize) { | |
43 comp_[index_++] = 1; | |
44 } | |
45 | 41 |
46 int year = 0; // Default year is 0 (=> 2000) for KJS compatibility. | 42 int year = 0; // Default year is 0 (=> 2000) for KJS compatibility. |
47 int month = kNone; | 43 int month = kNone; |
48 int day = kNone; | 44 int day = kNone; |
49 | 45 |
50 if (named_month_ == kNone) { | 46 if (named_month_ == kNone) { |
51 if (index_ < 2) return false; | |
52 if (index_ == 3 && !IsDay(comp_[0])) { | 47 if (index_ == 3 && !IsDay(comp_[0])) { |
53 // YMD | 48 // YMD |
54 year = comp_[0]; | 49 year = comp_[0]; |
55 month = comp_[1]; | 50 month = comp_[1]; |
56 day = comp_[2]; | 51 day = comp_[2]; |
57 } else { | 52 } else { |
58 // MD(Y) | 53 // MD(Y) |
59 month = comp_[0]; | 54 month = comp_[0]; |
60 day = comp_[1]; | 55 day = comp_[1]; |
61 if (index_ == 3) year = comp_[2]; | 56 if (index_ == 3) year = comp_[2]; |
62 } | 57 } |
63 } else { | 58 } else { |
64 month = named_month_; | 59 month = named_month_; |
65 if (index_ < 1) return false; | |
66 if (index_ == 1) { | 60 if (index_ == 1) { |
67 // MD or DM | 61 // MD or DM |
68 day = comp_[0]; | 62 day = comp_[0]; |
69 } else if (!IsDay(comp_[0])) { | 63 } else if (!IsDay(comp_[0])) { |
70 // YMD, MYD, or YDM | 64 // YMD, MYD, or YDM |
71 year = comp_[0]; | 65 year = comp_[0]; |
72 day = comp_[1]; | 66 day = comp_[1]; |
73 } else { | 67 } else { |
74 // DMY, MDY, or DYM | 68 // DMY, MDY, or DYM |
75 day = comp_[0]; | 69 day = comp_[0]; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 if (j == kPrefixLength && | 169 if (j == kPrefixLength && |
176 (len <= kPrefixLength || array[i][kTypeOffset] == MONTH_NAME)) { | 170 (len <= kPrefixLength || array[i][kTypeOffset] == MONTH_NAME)) { |
177 return i; | 171 return i; |
178 } | 172 } |
179 } | 173 } |
180 return i; | 174 return i; |
181 } | 175 } |
182 | 176 |
183 | 177 |
184 } } // namespace v8::internal | 178 } } // namespace v8::internal |
OLD | NEW |