35 bool DateParser::DayComposer::Write(FixedArray* output) {
36 if (index_ < 1)
return false;
38 while (index_ < kSize) {
46 if (named_month_ == kNone) {
47 if (is_iso_date_ || (index_ == 3 && !IsDay(comp_[0]))) {
56 if (index_ == 3) year = comp_[2];
63 }
else if (!IsDay(comp_[0])) {
75 if (Between(year, 0, 49)) year += 2000;
76 else if (Between(year, 50, 99)) year += 1900;
79 if (!
Smi::IsValid(year) || !IsMonth(month) || !IsDay(day))
return false;
88 bool DateParser::TimeComposer::Write(FixedArray* output) {
90 while (index_ < kSize) {
95 int& minute = comp_[1];
96 int& second = comp_[2];
97 int& millisecond = comp_[3];
99 if (hour_offset_ != kNone) {
100 if (!IsHour12(hour))
return false;
102 hour += hour_offset_;
105 if (!IsHour(hour) || !IsMinute(minute) ||
106 !IsSecond(second) || !IsMillisecond(millisecond))
return false;
116 bool DateParser::TimeZoneComposer::Write(FixedArray* output) {
117 if (sign_ != kNone) {
118 if (hour_ == kNone) hour_ = 0;
119 if (minute_ == kNone) minute_ = 0;
120 int total_seconds = sign_ * (hour_ * 3600 + minute_ * 60);
124 output->set_null(UTC_OFFSET);
129 const int8_t DateParser::KeywordTable::
130 array[][DateParser::KeywordTable::kEntrySize] = {
131 {
'j',
'a',
'n', DateParser::MONTH_NAME, 1},
132 {
'f',
'e',
'b', DateParser::MONTH_NAME, 2},
133 {
'm',
'a',
'r', DateParser::MONTH_NAME, 3},
134 {
'a',
'p',
'r', DateParser::MONTH_NAME, 4},
135 {
'm',
'a',
'y', DateParser::MONTH_NAME, 5},
136 {
'j',
'u',
'n', DateParser::MONTH_NAME, 6},
137 {
'j',
'u',
'l', DateParser::MONTH_NAME, 7},
138 {
'a',
'u',
'g', DateParser::MONTH_NAME, 8},
139 {
's',
'e',
'p', DateParser::MONTH_NAME, 9},
140 {
'o',
'c',
't', DateParser::MONTH_NAME, 10},
141 {
'n',
'o',
'v', DateParser::MONTH_NAME, 11},
142 {
'd',
'e',
'c', DateParser::MONTH_NAME, 12},
143 {
'a',
'm',
'\0', DateParser::AM_PM, 0},
144 {
'p',
'm',
'\0', DateParser::AM_PM, 12},
145 {
'u',
't',
'\0', DateParser::TIME_ZONE_NAME, 0},
146 {
'u',
't',
'c', DateParser::TIME_ZONE_NAME, 0},
147 {
'z',
'\0',
'\0', DateParser::TIME_ZONE_NAME, 0},
148 {
'g',
'm',
't', DateParser::TIME_ZONE_NAME, 0},
149 {
'c',
'd',
't', DateParser::TIME_ZONE_NAME, -5},
150 {
'c',
's',
't', DateParser::TIME_ZONE_NAME, -6},
151 {
'e',
'd',
't', DateParser::TIME_ZONE_NAME, -4},
152 {
'e',
's',
't', DateParser::TIME_ZONE_NAME, -5},
153 {
'm',
'd',
't', DateParser::TIME_ZONE_NAME, -6},
154 {
'm',
's',
't', DateParser::TIME_ZONE_NAME, -7},
155 {
'p',
'd',
't', DateParser::TIME_ZONE_NAME, -7},
156 {
'p',
's',
't', DateParser::TIME_ZONE_NAME, -8},
157 {
't',
'\0',
'\0', DateParser::TIME_SEPARATOR, 0},
158 {
'\0',
'\0',
'\0', DateParser::INVALID, 0},
163 int DateParser::KeywordTable::Lookup(
const uint32_t* pre,
int len) {
165 for (i = 0; array[i][kTypeOffset] != INVALID; i++) {
167 while (j < kPrefixLength &&
168 pre[j] == static_cast<uint32_t>(array[i][j])) {
173 if (j == kPrefixLength &&
174 (len <= kPrefixLength || array[i][kTypeOffset] == MONTH_NAME)) {
182 int DateParser::ReadMilliseconds(DateToken token) {
187 int number = token.number();
188 int length = token.length();
194 }
else if (length == 2) {
197 }
else if (length > 3) {
198 if (length > kMaxSignificantDigits) length = kMaxSignificantDigits;
203 ASSERT(factor <= 100000000);
206 }
while (length > 3);
static Smi * FromInt(int value)
#define ASSERT(condition)
static bool IsValid(intptr_t value)