Changeset 10675 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Sep 30, 2005, 9:16:13 AM (20 years ago)
Author:
ggaren
Message:
  • 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/date_object.cpp

    r10655 r10675  
    10921092     //
    10931093     double result = -1;
    1094      long offset = 0;
     1094     int offset = 0;
    10951095     bool have_tz = false;
    10961096     char *newPosStr;
     
    13011301     }
    13021302
     1303     // Don't fail if the time zone is missing.
     1304     // Some websites omit the time zone (4275206).
    13031305     if (*dateString) {
    13041306       if (strncasecmp(dateString, "GMT", 3) == 0 ||
     
    13391341           if (0 == strncasecmp(dateString, known_zones[i].tzName, strlen(known_zones[i].tzName))) {
    13401342             offset = known_zones[i].tzOffset;
     1343             dateString += strlen(known_zones[i].tzName);
    13411344             have_tz = true;
    13421345             break;
    13431346           }
    13441347         }
    1345          // If the time zone is missing or malformed, substitute the local time zone.
    1346          // Some websites (4275206) omit the time zone.
    1347          if (!have_tz) {
    1348            time_t now;
    1349            struct tm t;
    1350            
    1351            time(&now);
    1352            if (now == -1)
    1353              return invalidDate;
    1354            
    1355            localtime_r(&now, &t);
    1356            offset = -timeZoneOffset(&t);
    1357            
    1358            have_tz = true;
    1359          }
    13601348       }
    13611349     }
     
    13681356       if (errno)
    13691357         return invalidDate;
     1358       dateString = newPosStr;
    13701359     }
     1360     
     1361     while (isspace(*dateString))
     1362       dateString++;
     1363     
     1364     // Trailing garbage
     1365     if (*dateString != '\0')
     1366       return invalidDate;
    13711367
    13721368     // Y2K: Solve 2 digit years
     
    13771373         year += 1900;  // Y2K
    13781374
     1375     // fall back to midnight, local timezone
    13791376     if (!have_tz) {
    1380        // fall back to midnight, local timezone
    13811377       struct tm t;
    13821378       memset(&t, 0, sizeof(tm));
     
    13951391     }
    13961392     
    1397      result = ymdhms_to_seconds(year, month+1, day, hour, minute, second) - (offset * 60);
     1393     result = ymdhms_to_seconds(year, month + 1, day, hour, minute, second) - (offset * 60);
    13981394     return result;
    13991395}
Note: See TracChangeset for help on using the changeset viewer.