summaryrefslogtreecommitdiffstats
path: root/src/dateparser.cc
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-12-02 17:19:32 +0000
committerBen Murdoch <benm@google.com>2011-12-02 17:27:49 +0000
commit3fb3ca8c7ca439d408449a395897395c0faae8d1 (patch)
tree5cb33db083ae7ebe431e2a460fb3806c54531f9c /src/dateparser.cc
parent257744e915dfc84d6d07a6b2accf8402d9ffc708 (diff)
downloadandroid_external_v8-3fb3ca8c7ca439d408449a395897395c0faae8d1.tar.gz
android_external_v8-3fb3ca8c7ca439d408449a395897395c0faae8d1.tar.bz2
android_external_v8-3fb3ca8c7ca439d408449a395897395c0faae8d1.zip
Upgrade to V8 3.4
Merge 3.4.14.35 Simple merge required updates to makefiles only. Bug: 568872 Change-Id: I403a38452c547e06fcfa951c12eca12a1bc40978
Diffstat (limited to 'src/dateparser.cc')
-rw-r--r--src/dateparser.cc42
1 files changed, 38 insertions, 4 deletions
diff --git a/src/dateparser.cc b/src/dateparser.cc
index 6d804887..4a0721fe 100644
--- a/src/dateparser.cc
+++ b/src/dateparser.cc
@@ -1,4 +1,4 @@
-// Copyright 2008 the V8 project authors. All rights reserved.
+// Copyright 2011 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -44,7 +44,7 @@ bool DateParser::DayComposer::Write(FixedArray* output) {
int day = kNone;
if (named_month_ == kNone) {
- if (index_ == 3 && !IsDay(comp_[0])) {
+ if (is_iso_date_ || (index_ == 3 && !IsDay(comp_[0]))) {
// YMD
year = comp_[0];
month = comp_[1];
@@ -71,8 +71,10 @@ bool DateParser::DayComposer::Write(FixedArray* output) {
}
}
- if (Between(year, 0, 49)) year += 2000;
- else if (Between(year, 50, 99)) year += 1900;
+ if (!is_iso_date_) {
+ if (Between(year, 0, 49)) year += 2000;
+ else if (Between(year, 50, 99)) year += 1900;
+ }
if (!Smi::IsValid(year) || !IsMonth(month) || !IsDay(day)) return false;
@@ -151,6 +153,7 @@ const int8_t DateParser::KeywordTable::
{'m', 's', 't', DateParser::TIME_ZONE_NAME, -7},
{'p', 'd', 't', DateParser::TIME_ZONE_NAME, -7},
{'p', 's', 't', DateParser::TIME_ZONE_NAME, -8},
+ {'t', '\0', '\0', DateParser::TIME_SEPARATOR, 0},
{'\0', '\0', '\0', DateParser::INVALID, 0},
};
@@ -175,4 +178,35 @@ int DateParser::KeywordTable::Lookup(const uint32_t* pre, int len) {
}
+int DateParser::ReadMilliseconds(DateToken token) {
+ // Read first three significant digits of the original numeral,
+ // as inferred from the value and the number of digits.
+ // I.e., use the number of digits to see if there were
+ // leading zeros.
+ int number = token.number();
+ int length = token.length();
+ if (length < 3) {
+ // Less than three digits. Multiply to put most significant digit
+ // in hundreds position.
+ if (length == 1) {
+ number *= 100;
+ } else if (length == 2) {
+ number *= 10;
+ }
+ } else if (length > 3) {
+ if (length > kMaxSignificantDigits) length = kMaxSignificantDigits;
+ // More than three digits. Divide by 10^(length - 3) to get three
+ // most significant digits.
+ int factor = 1;
+ do {
+ ASSERT(factor <= 100000000); // factor won't overflow.
+ factor *= 10;
+ length--;
+ } while (length > 3);
+ number /= factor;
+ }
+ return number;
+}
+
+
} } // namespace v8::internal