[webkit-changes] cvs commit: JavaScriptCore/kjs date_object.cpp
Geoffrey
ggaren at opensource.apple.com
Fri Sep 30 09:16:14 PDT 2005
ggaren 05/09/30 09:16:13
Modified: . ChangeLog
kjs date_object.cpp
Log:
- Second cut at fixing <rdar://problem/4275206> Denver Regression: Seed:
Past Editions of Opinions display "NAN/Undefined" for www.washingtonpost.com
Reviewed by john.
* kjs/date_object.cpp:
(KJS::KRFCDate_parseDate): Intead of creating a timezone when one isn't specified,
just rely on the fallback logic, which will do it for you. Also, return invalidDate
if the date includes trailing garbage. (Somewhat accidentally, the timezone logic
used to catch trailing garbage.)
Added test case to fast/js/date-parse-test.html.
Revision Changes Path
1.848 +15 -0 JavaScriptCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/JavaScriptCore/ChangeLog,v
retrieving revision 1.847
retrieving revision 1.848
diff -u -r1.847 -r1.848
--- ChangeLog 29 Sep 2005 22:05:10 -0000 1.847
+++ ChangeLog 30 Sep 2005 16:16:12 -0000 1.848
@@ -1,3 +1,18 @@
+2005-09-30 Geoffrey Garen <ggaren at apple.com>
+
+ - Second cut at fixing <rdar://problem/4275206> Denver Regression: Seed:
+ Past Editions of Opinions display "NAN/Undefined" for www.washingtonpost.com
+
+ Reviewed by john.
+
+ * kjs/date_object.cpp:
+ (KJS::KRFCDate_parseDate): Intead of creating a timezone when one isn't specified,
+ just rely on the fallback logic, which will do it for you. Also, return invalidDate
+ if the date includes trailing garbage. (Somewhat accidentally, the timezone logic
+ used to catch trailing garbage.)
+
+ Added test case to fast/js/date-parse-test.html.
+
2005-09-29 Eric Seidel <eseidel at apple.com>
Fix from Mitz Pettel <opendarwin.org at mitzpettel.com>
1.58 +14 -18 JavaScriptCore/kjs/date_object.cpp
Index: date_object.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/date_object.cpp,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- date_object.cpp 29 Sep 2005 01:55:11 -0000 1.57
+++ date_object.cpp 30 Sep 2005 16:16:13 -0000 1.58
@@ -1091,7 +1091,7 @@
// We ignore the weekday
//
double result = -1;
- long offset = 0;
+ int offset = 0;
bool have_tz = false;
char *newPosStr;
const char *dateString = _date.ascii();
@@ -1300,6 +1300,8 @@
dateString = newPosStr;
}
+ // Don't fail if the time zone is missing.
+ // Some websites omit the time zone (4275206).
if (*dateString) {
if (strncasecmp(dateString, "GMT", 3) == 0 ||
strncasecmp(dateString, "UTC", 3) == 0) {
@@ -1338,25 +1340,11 @@
for (int i=0; i < int(sizeof(known_zones)/sizeof(KnownZone)); i++) {
if (0 == strncasecmp(dateString, known_zones[i].tzName, strlen(known_zones[i].tzName))) {
offset = known_zones[i].tzOffset;
+ dateString += strlen(known_zones[i].tzName);
have_tz = true;
break;
}
}
- // If the time zone is missing or malformed, substitute the local time zone.
- // Some websites (4275206) omit the time zone.
- if (!have_tz) {
- time_t now;
- struct tm t;
-
- time(&now);
- if (now == -1)
- return invalidDate;
-
- localtime_r(&now, &t);
- offset = -timeZoneOffset(&t);
-
- have_tz = true;
- }
}
}
@@ -1367,7 +1355,15 @@
year = strtol(dateString, &newPosStr, 10);
if (errno)
return invalidDate;
+ dateString = newPosStr;
}
+
+ while (isspace(*dateString))
+ dateString++;
+
+ // Trailing garbage
+ if (*dateString != '\0')
+ return invalidDate;
// Y2K: Solve 2 digit years
if ((year >= 0) && (year < 50))
@@ -1376,8 +1372,8 @@
if ((year >= 50) && (year < 100))
year += 1900; // Y2K
+ // fall back to midnight, local timezone
if (!have_tz) {
- // fall back to midnight, local timezone
struct tm t;
memset(&t, 0, sizeof(tm));
t.tm_mday = day;
@@ -1394,7 +1390,7 @@
return makeTime(&t, 0, false) / 1000.0;
}
- result = ymdhms_to_seconds(year, month+1, day, hour, minute, second) - (offset * 60);
+ result = ymdhms_to_seconds(year, month + 1, day, hour, minute, second) - (offset * 60);
return result;
}
More information about the webkit-changes
mailing list