Changeset 44929 in webkit
- Timestamp:
- Jun 21, 2009 10:08:10 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r44924 r44929 1 2009-06-21 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 Bug 26594: JSC needs to support Date.toISOString 6 <https://bugs.webkit.org/show_bug.cgi?id=26594> 7 8 Add support for Date.toISOString. 9 10 * runtime/DatePrototype.cpp: 11 (JSC::dateProtoFuncToISOString): 12 1 13 2009-06-21 Oliver Hunt <oliver@apple.com> 2 14 -
trunk/JavaScriptCore/runtime/DatePrototype.cpp
r44866 r44929 114 114 static JSValue JSC_HOST_CALL dateProtoFuncToTimeString(ExecState*, JSObject*, JSValue, const ArgList&); 115 115 static JSValue JSC_HOST_CALL dateProtoFuncToUTCString(ExecState*, JSObject*, JSValue, const ArgList&); 116 static JSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState*, JSObject*, JSValue, const ArgList&); 116 117 117 118 } … … 343 344 @begin dateTable 344 345 toString dateProtoFuncToString DontEnum|Function 0 346 toISOString dateProtoFuncToISOString DontEnum|Function 0 345 347 toUTCString dateProtoFuncToUTCString DontEnum|Function 0 346 348 toDateString dateProtoFuncToDateString DontEnum|Function 0 … … 439 441 } 440 442 443 JSValue JSC_HOST_CALL dateProtoFuncToISOString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) 444 { 445 if (!thisValue.isObject(&DateInstance::info)) 446 return throwError(exec, TypeError); 447 448 const bool utc = true; 449 450 DateInstance* thisDateObj = asDateInstance(thisValue); 451 double milli = thisDateObj->internalNumber(); 452 if (!isfinite(milli)) 453 return jsNontrivialString(exec, "Invalid Date"); 454 455 GregorianDateTime t; 456 thisDateObj->msToGregorianDateTime(milli, utc, t); 457 // Maximum amount of space we need in buffer: 6 (max. digits in year) + 2 * 5 (2 characters each for month, day, hour, minute, second) 458 // 6 for formatting and one for null termination = 23. We add one extra character to allow us to force null termination. 459 char buffer[24]; 460 snprintf(buffer, sizeof(buffer) - 1, "%04d-%02d-%02dT%02d:%02d:%02dZ", 1900 + t.year, t.month + 1, t.monthDay, t.hour, t.minute, t.second); 461 buffer[sizeof(buffer) - 1] = 0; 462 return jsNontrivialString(exec, buffer); 463 } 464 441 465 JSValue JSC_HOST_CALL dateProtoFuncToDateString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) 442 466 { -
trunk/LayoutTests/ChangeLog
r44928 r44929 1 2009-06-21 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 Bug 26594: JSC needs to support Date.toISOString 6 <https://bugs.webkit.org/show_bug.cgi?id=26594> 7 8 A few basic correctness tests for Date.toISOString. 9 10 * fast/js/date-toisostring-expected.txt: Added. 11 * fast/js/date-toisostring.html: Added. 12 * fast/js/resources/date-toisostring.js: Added. 13 1 14 2009-06-21 Sam Weinig <sam@webkit.org> 2 15
Note: See TracChangeset
for help on using the changeset viewer.