[webkit-changes] cvs commit: JavaScriptCore/kjs date_object.cpp
Timothy
thatcher at opensource.apple.com
Fri Sep 30 10:55:30 PDT 2005
thatcher 05/09/30 10:55:30
Modified: . Tag: Safari-2-0-branch ChangeLog
kjs Tag: Safari-2-0-branch date_object.cpp
Log:
Merges fixes from TOT to Safari-2-0-branch
2005-09-29 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 mjs.
* 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.)
Revision Changes Path
No revision
No revision
1.677.6.41 +17 -0 JavaScriptCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/JavaScriptCore/ChangeLog,v
retrieving revision 1.677.6.40
retrieving revision 1.677.6.41
diff -u -r1.677.6.40 -r1.677.6.41
--- ChangeLog 29 Sep 2005 02:58:06 -0000 1.677.6.40
+++ ChangeLog 30 Sep 2005 17:55:28 -0000 1.677.6.41
@@ -1,3 +1,20 @@
+2005-09-30 Timothy Hatcher <timothy at apple.com>
+
+ Merges fixes from TOT to Safari-2-0-branch
+
+ 2005-09-29 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 mjs.
+
+ * 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.)
+
=== JavaScriptCore-417 ===
2005-09-28 Timothy Hatcher <timothy at apple.com>
No revision
No revision
1.39.8.4 +14 -18 JavaScriptCore/kjs/date_object.cpp
Index: date_object.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/date_object.cpp,v
retrieving revision 1.39.8.3
retrieving revision 1.39.8.4
diff -u -r1.39.8.3 -r1.39.8.4
--- date_object.cpp 29 Sep 2005 02:58:07 -0000 1.39.8.3
+++ date_object.cpp 30 Sep 2005 17:55:29 -0000 1.39.8.4
@@ -1036,7 +1036,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();
@@ -1247,6 +1247,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) {
@@ -1285,25 +1287,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;
- }
}
}
@@ -1314,7 +1302,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))
@@ -1323,8 +1319,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;
@@ -1341,7 +1337,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