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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 int n = in.ReadUnsignedNumber(); | 47 int n = in.ReadUnsignedNumber(); |
48 if (in.Skip(':')) { | 48 if (in.Skip(':')) { |
49 if (in.Skip(':')) { | 49 if (in.Skip(':')) { |
50 // n + "::" | 50 // n + "::" |
51 if (!time.IsEmpty()) return false; | 51 if (!time.IsEmpty()) return false; |
52 time.Add(n); | 52 time.Add(n); |
53 time.Add(0); | 53 time.Add(0); |
54 } else { | 54 } else { |
55 // n + ":" | 55 // n + ":" |
56 if (!time.Add(n)) return false; | 56 if (!time.Add(n)) return false; |
| 57 in.Skip('.'); |
57 } | 58 } |
| 59 } else if (in.Skip('.') && time.IsExpecting(n)) { |
| 60 time.Add(n); |
| 61 if (!in.IsAsciiDigit()) return false; |
| 62 int n = in.ReadUnsignedNumber(); |
| 63 time.AddFinal(n); |
58 } else if (tz.IsExpecting(n)) { | 64 } else if (tz.IsExpecting(n)) { |
59 tz.SetAbsoluteMinute(n); | 65 tz.SetAbsoluteMinute(n); |
60 } else if (time.IsExpecting(n)) { | 66 } else if (time.IsExpecting(n)) { |
61 time.AddFinal(n); | 67 time.AddFinal(n); |
62 // Require end or white space immediately after finalizing time. | 68 // Require end, white space or Z immediately after finalizing time. |
63 if (!in.IsEnd() && !in.SkipWhiteSpace()) return false; | 69 if (!in.IsEnd() && !in.SkipWhiteSpace() && !in.Is('Z')) return false; |
64 } else { | 70 } else { |
65 if (!day.Add(n)) return false; | 71 if (!day.Add(n)) return false; |
66 in.Skip('-'); // Ignore suffix '-' for year, month, or day. | 72 in.Skip('-'); // Ignore suffix '-' for year, month, or day. |
| 73 // Skip trailing 'T' for ECMAScript 5 date string format but make |
| 74 // sure that it is followed by a digit (for the time). |
| 75 if (in.Skip('T') && !in.IsAsciiDigit()) return false; |
67 } | 76 } |
68 } else if (in.IsAsciiAlphaOrAbove()) { | 77 } else if (in.IsAsciiAlphaOrAbove()) { |
69 // Parse a "word" (sequence of chars. >= 'A'). | 78 // Parse a "word" (sequence of chars. >= 'A'). |
70 uint32_t pre[KeywordTable::kPrefixLength]; | 79 uint32_t pre[KeywordTable::kPrefixLength]; |
71 int len = in.ReadWord(pre, KeywordTable::kPrefixLength); | 80 int len = in.ReadWord(pre, KeywordTable::kPrefixLength); |
72 int index = KeywordTable::Lookup(pre, len); | 81 int index = KeywordTable::Lookup(pre, len); |
73 KeywordType type = KeywordTable::GetType(index); | 82 KeywordType type = KeywordTable::GetType(index); |
74 | 83 |
75 if (type == AM_PM && !time.IsEmpty()) { | 84 if (type == AM_PM && !time.IsEmpty()) { |
76 time.SetHourOffset(KeywordTable::GetValue(index)); | 85 time.SetHourOffset(KeywordTable::GetValue(index)); |
(...skipping 28 matching lines...) Expand all Loading... |
105 // Ignore other characters. | 114 // Ignore other characters. |
106 in.Next(); | 115 in.Next(); |
107 } | 116 } |
108 } | 117 } |
109 return day.Write(out) && time.Write(out) && tz.Write(out); | 118 return day.Write(out) && time.Write(out) && tz.Write(out); |
110 } | 119 } |
111 | 120 |
112 } } // namespace v8::internal | 121 } } // namespace v8::internal |
113 | 122 |
114 #endif // V8_DATEPARSER_INL_H_ | 123 #endif // V8_DATEPARSER_INL_H_ |
OLD | NEW |