[webkit-changes] cvs commit: JavaScriptCore/kjs date_object.cpp

Timothy thatcher at opensource.apple.com
Fri Sep 30 10:45:42 PDT 2005


thatcher    05/09/30 10:45:42

  Modified:    .        Tag: Safari-Den-branch ChangeLog
               kjs      Tag: Safari-Den-branch date_object.cpp
  Log:
  	    Merges fixes from TOT to Safari-Den-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.34.2.9 +17 -0     JavaScriptCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/ChangeLog,v
  retrieving revision 1.677.6.34.2.8
  retrieving revision 1.677.6.34.2.9
  diff -u -r1.677.6.34.2.8 -r1.677.6.34.2.9
  --- ChangeLog	29 Sep 2005 02:59:46 -0000	1.677.6.34.2.8
  +++ ChangeLog	30 Sep 2005 17:45:38 -0000	1.677.6.34.2.9
  @@ -1,5 +1,22 @@
   === JavaScriptCore-416.10 ===
   
  +2005-09-30  Timothy Hatcher  <timothy at apple.com>
  +
  +	    Merges fixes from TOT to Safari-Den-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.)
  +
   2005-09-28  Timothy Hatcher  <timothy at apple.com>
   
   	    Merges fixes from TOT to Safari-Den-branch
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.39.8.1.2.3 +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.1.2.2
  retrieving revision 1.39.8.1.2.3
  diff -u -r1.39.8.1.2.2 -r1.39.8.1.2.3
  --- date_object.cpp	29 Sep 2005 02:59:47 -0000	1.39.8.1.2.2
  +++ date_object.cpp	30 Sep 2005 17:45:41 -0000	1.39.8.1.2.3
  @@ -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