Changeset 49886 in webkit for trunk/JavaScriptCore/runtime
- Timestamp:
- Oct 20, 2009, 2:39:43 PM (16 years ago)
- Location:
- trunk/JavaScriptCore/runtime
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/DateInstance.cpp
r49217 r49886 60 60 } 61 61 62 void DateInstance::msToGregorianDateTime(double milli,bool outputIsUTC, GregorianDateTime& t) const62 bool DateInstance::getGregorianDateTime(bool outputIsUTC, GregorianDateTime& t) const 63 63 { 64 64 if (!m_cache) { … … 68 68 } 69 69 70 double milli = internalNumber(); 71 if (isnan(milli)) 72 return false; 73 70 74 if (outputIsUTC) { 71 75 if (m_cache->m_gregorianDateTimeUTCCachedForMS != milli) { 72 WTF::msToGregorianDateTime( milli, true, m_cache->m_cachedGregorianDateTimeUTC);76 WTF::msToGregorianDateTime(internalNumber(), true, m_cache->m_cachedGregorianDateTimeUTC); 73 77 m_cache->m_gregorianDateTimeUTCCachedForMS = milli; 74 78 } … … 76 80 } else { 77 81 if (m_cache->m_gregorianDateTimeCachedForMS != milli) { 78 WTF::msToGregorianDateTime( milli, false, m_cache->m_cachedGregorianDateTime);82 WTF::msToGregorianDateTime(internalNumber(), false, m_cache->m_cachedGregorianDateTime); 79 83 m_cache->m_gregorianDateTimeCachedForMS = milli; 80 84 } 81 85 t.copyFrom(m_cache->m_cachedGregorianDateTime); 82 86 } 87 88 return true; 83 89 } 84 90 -
trunk/JavaScriptCore/runtime/DateInstance.h
r49845 r49886 45 45 static JS_EXPORTDATA const ClassInfo info; 46 46 47 void msToGregorianDateTime(double,bool outputIsUTC, WTF::GregorianDateTime&) const;47 bool getGregorianDateTime(bool outputIsUTC, WTF::GregorianDateTime&) const; 48 48 49 49 static PassRefPtr<Structure> createStructure(JSValue prototype) … … 58 58 virtual const ClassInfo* classInfo() const { return &info; } 59 59 60 using JSWrapperObject::internalValue;61 60 62 61 struct Cache; -
trunk/JavaScriptCore/runtime/DatePrototype.cpp
r48836 r49886 252 252 } 253 253 254 static JSCell* formatLocaleDate(ExecState* exec, DateInstance* dateObject, double timeInMilliseconds, LocaleDateTimeFormat format, const ArgList&)254 static JSCell* formatLocaleDate(ExecState* exec, DateInstance* dateObject, double, LocaleDateTimeFormat format, const ArgList&) 255 255 { 256 256 GregorianDateTime gregorianDateTime; 257 257 const bool notUTC = false; 258 dateObject->msToGregorianDateTime(timeInMilliseconds, notUTC, gregorianDateTime); 258 if (!dateObject->getGregorianDateTime(outputIsUTC, gregorianDateTime)) 259 return jsNontrivialString(exec, "Invalid Date"); 259 260 return formatLocaleDate(exec, gregorianDateTime, format); 260 261 } … … 421 422 return throwError(exec, TypeError); 422 423 423 const bool utc = false; 424 425 DateInstance* thisDateObj = asDateInstance(thisValue); 426 double milli = thisDateObj->internalNumber(); 427 if (isnan(milli)) 424 const bool outputIsUTC = false; 425 426 DateInstance* thisDateObj = asDateInstance(thisValue); 427 428 GregorianDateTime t; 429 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 428 430 return jsNontrivialString(exec, "Invalid Date"); 429 430 GregorianDateTime t; 431 thisDateObj->msToGregorianDateTime(milli, utc, t); 432 return jsNontrivialString(exec, formatDate(t) + " " + formatTime(t, utc)); 431 return jsNontrivialString(exec, formatDate(t) + " " + formatTime(t, outputIsUTC)); 433 432 } 434 433 … … 438 437 return throwError(exec, TypeError); 439 438 440 const bool utc = true; 441 442 DateInstance* thisDateObj = asDateInstance(thisValue); 443 double milli = thisDateObj->internalNumber(); 444 if (isnan(milli)) 439 const bool outputIsUTC = true; 440 441 DateInstance* thisDateObj = asDateInstance(thisValue); 442 443 GregorianDateTime t; 444 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 445 445 return jsNontrivialString(exec, "Invalid Date"); 446 447 GregorianDateTime t; 448 thisDateObj->msToGregorianDateTime(milli, utc, t); 449 return jsNontrivialString(exec, formatDateUTCVariant(t) + " " + formatTime(t, utc)); 446 return jsNontrivialString(exec, formatDateUTCVariant(t) + " " + formatTime(t, outputIsUTC)); 450 447 } 451 448 … … 455 452 return throwError(exec, TypeError); 456 453 457 const bool utc = true; 458 459 DateInstance* thisDateObj = asDateInstance(thisValue); 460 double milli = thisDateObj->internalNumber(); 461 if (!isfinite(milli)) 454 const bool outputIsUTC = true; 455 456 DateInstance* thisDateObj = asDateInstance(thisValue); 457 458 GregorianDateTime t; 459 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 462 460 return jsNontrivialString(exec, "Invalid Date"); 463 464 GregorianDateTime t;465 thisDateObj->msToGregorianDateTime(milli, utc, t);466 461 // Maximum amount of space we need in buffer: 6 (max. digits in year) + 2 * 5 (2 characters each for month, day, hour, minute, second) + 4 (. + 3 digits for milliseconds) 467 462 // 6 for formatting and one for null termination = 27. We add one extra character to allow us to force null termination. 468 463 char buffer[28]; 469 snprintf(buffer, sizeof(buffer) - 1, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", 1900 + t.year, t.month + 1, t.monthDay, t.hour, t.minute, t.second, static_cast<int>(fmod( milli, 1000)));464 snprintf(buffer, sizeof(buffer) - 1, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", 1900 + t.year, t.month + 1, t.monthDay, t.hour, t.minute, t.second, static_cast<int>(fmod(thisDateObj->internalNumber(), 1000))); 470 465 buffer[sizeof(buffer) - 1] = 0; 471 466 return jsNontrivialString(exec, buffer); … … 477 472 return throwError(exec, TypeError); 478 473 479 const bool utc = false; 480 481 DateInstance* thisDateObj = asDateInstance(thisValue); 482 double milli = thisDateObj->internalNumber(); 483 if (isnan(milli)) 474 const bool outputIsUTC = false; 475 476 DateInstance* thisDateObj = asDateInstance(thisValue); 477 478 GregorianDateTime t; 479 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 484 480 return jsNontrivialString(exec, "Invalid Date"); 485 486 GregorianDateTime t;487 thisDateObj->msToGregorianDateTime(milli, utc, t);488 481 return jsNontrivialString(exec, formatDate(t)); 489 482 } … … 494 487 return throwError(exec, TypeError); 495 488 496 const bool utc = false; 497 498 DateInstance* thisDateObj = asDateInstance(thisValue); 499 double milli = thisDateObj->internalNumber(); 500 if (isnan(milli)) 489 const bool outputIsUTC = false; 490 491 DateInstance* thisDateObj = asDateInstance(thisValue); 492 493 GregorianDateTime t; 494 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 501 495 return jsNontrivialString(exec, "Invalid Date"); 502 503 GregorianDateTime t; 504 thisDateObj->msToGregorianDateTime(milli, utc, t); 505 return jsNontrivialString(exec, formatTime(t, utc)); 496 return jsNontrivialString(exec, formatTime(t, outputIsUTC)); 506 497 } 507 498 … … 512 503 513 504 DateInstance* thisDateObj = asDateInstance(thisValue); 514 double milli = thisDateObj->internalNumber(); 515 if (isnan(milli)) 505 return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleDateAndTime, args); 506 } 507 508 JSValue JSC_HOST_CALL dateProtoFuncToLocaleDateString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) 509 { 510 if (!thisValue.inherits(&DateInstance::info)) 511 return throwError(exec, TypeError); 512 513 DateInstance* thisDateObj = asDateInstance(thisValue); 514 return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleDate, args); 515 } 516 517 JSValue JSC_HOST_CALL dateProtoFuncToLocaleTimeString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) 518 { 519 if (!thisValue.inherits(&DateInstance::info)) 520 return throwError(exec, TypeError); 521 522 DateInstance* thisDateObj = asDateInstance(thisValue); 523 return formatLocaleDate(exec, thisDateObj, thisDateObj->internalNumber(), LocaleTime, args); 524 } 525 526 JSValue JSC_HOST_CALL dateProtoFuncGetTime(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) 527 { 528 if (!thisValue.inherits(&DateInstance::info)) 529 return throwError(exec, TypeError); 530 531 return asDateInstance(thisValue)->internalValue(); 532 } 533 534 JSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) 535 { 536 if (!thisValue.inherits(&DateInstance::info)) 537 return throwError(exec, TypeError); 538 539 const bool outputIsUTC = false; 540 541 DateInstance* thisDateObj = asDateInstance(thisValue); 542 543 GregorianDateTime t; 544 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 545 return jsNaN(exec); 546 return jsNumber(exec, 1900 + t.year); 547 } 548 549 JSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) 550 { 551 if (!thisValue.inherits(&DateInstance::info)) 552 return throwError(exec, TypeError); 553 554 const bool outputIsUTC = true; 555 556 DateInstance* thisDateObj = asDateInstance(thisValue); 557 558 GregorianDateTime t; 559 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 560 return jsNaN(exec); 561 return jsNumber(exec, 1900 + t.year); 562 } 563 564 JSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) 565 { 566 if (!thisValue.inherits(&DateInstance::info)) 567 return throwError(exec, TypeError); 568 569 const bool outputIsUTC = true; 570 571 DateInstance* thisDateObj = asDateInstance(thisValue); 572 573 GregorianDateTime t; 574 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 516 575 return jsNontrivialString(exec, "Invalid Date"); 517 518 return formatLocaleDate(exec, thisDateObj, milli, LocaleDateAndTime, args); 519 } 520 521 JSValue JSC_HOST_CALL dateProtoFuncToLocaleDateString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) 522 { 523 if (!thisValue.inherits(&DateInstance::info)) 524 return throwError(exec, TypeError); 525 526 DateInstance* thisDateObj = asDateInstance(thisValue); 527 double milli = thisDateObj->internalNumber(); 528 if (isnan(milli)) 529 return jsNontrivialString(exec, "Invalid Date"); 530 531 return formatLocaleDate(exec, thisDateObj, milli, LocaleDate, args); 532 } 533 534 JSValue JSC_HOST_CALL dateProtoFuncToLocaleTimeString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) 535 { 536 if (!thisValue.inherits(&DateInstance::info)) 537 return throwError(exec, TypeError); 538 539 DateInstance* thisDateObj = asDateInstance(thisValue); 540 double milli = thisDateObj->internalNumber(); 541 if (isnan(milli)) 542 return jsNontrivialString(exec, "Invalid Date"); 543 544 return formatLocaleDate(exec, thisDateObj, milli, LocaleTime, args); 545 } 546 547 JSValue JSC_HOST_CALL dateProtoFuncGetTime(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) 548 { 549 if (!thisValue.inherits(&DateInstance::info)) 550 return throwError(exec, TypeError); 551 552 DateInstance* thisDateObj = asDateInstance(thisValue); 553 double milli = thisDateObj->internalNumber(); 554 if (isnan(milli)) 555 return jsNaN(exec); 556 557 return jsNumber(exec, milli); 558 } 559 560 JSValue JSC_HOST_CALL dateProtoFuncGetFullYear(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) 561 { 562 if (!thisValue.inherits(&DateInstance::info)) 563 return throwError(exec, TypeError); 564 565 const bool utc = false; 566 567 DateInstance* thisDateObj = asDateInstance(thisValue); 568 double milli = thisDateObj->internalNumber(); 569 if (isnan(milli)) 570 return jsNaN(exec); 571 572 GregorianDateTime t; 573 thisDateObj->msToGregorianDateTime(milli, utc, t); 574 return jsNumber(exec, 1900 + t.year); 575 } 576 577 JSValue JSC_HOST_CALL dateProtoFuncGetUTCFullYear(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) 578 { 579 if (!thisValue.inherits(&DateInstance::info)) 580 return throwError(exec, TypeError); 581 582 const bool utc = true; 583 584 DateInstance* thisDateObj = asDateInstance(thisValue); 585 double milli = thisDateObj->internalNumber(); 586 if (isnan(milli)) 587 return jsNaN(exec); 588 589 GregorianDateTime t; 590 thisDateObj->msToGregorianDateTime(milli, utc, t); 591 return jsNumber(exec, 1900 + t.year); 592 } 593 594 JSValue JSC_HOST_CALL dateProtoFuncToGMTString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&) 595 { 596 if (!thisValue.inherits(&DateInstance::info)) 597 return throwError(exec, TypeError); 598 599 const bool utc = true; 600 601 DateInstance* thisDateObj = asDateInstance(thisValue); 602 double milli = thisDateObj->internalNumber(); 603 if (isnan(milli)) 604 return jsNontrivialString(exec, "Invalid Date"); 605 606 GregorianDateTime t; 607 thisDateObj->msToGregorianDateTime(milli, utc, t); 608 return jsNontrivialString(exec, formatDateUTCVariant(t) + " " + formatTime(t, utc)); 576 return jsNontrivialString(exec, formatDateUTCVariant(t) + " " + formatTime(t, outputIsUTC)); 609 577 } 610 578 … … 614 582 return throwError(exec, TypeError); 615 583 616 const bool utc = false; 617 618 DateInstance* thisDateObj = asDateInstance(thisValue); 619 double milli = thisDateObj->internalNumber(); 620 if (isnan(milli)) 621 return jsNaN(exec); 622 623 GregorianDateTime t; 624 thisDateObj->msToGregorianDateTime(milli, utc, t); 584 const bool outputIsUTC = false; 585 586 DateInstance* thisDateObj = asDateInstance(thisValue); 587 588 GregorianDateTime t; 589 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 590 return jsNaN(exec); 625 591 return jsNumber(exec, t.month); 626 592 } … … 631 597 return throwError(exec, TypeError); 632 598 633 const bool utc = true; 634 635 DateInstance* thisDateObj = asDateInstance(thisValue); 636 double milli = thisDateObj->internalNumber(); 637 if (isnan(milli)) 638 return jsNaN(exec); 639 640 GregorianDateTime t; 641 thisDateObj->msToGregorianDateTime(milli, utc, t); 599 const bool outputIsUTC = true; 600 601 DateInstance* thisDateObj = asDateInstance(thisValue); 602 603 GregorianDateTime t; 604 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 605 return jsNaN(exec); 642 606 return jsNumber(exec, t.month); 643 607 } … … 648 612 return throwError(exec, TypeError); 649 613 650 const bool utc = false; 651 652 DateInstance* thisDateObj = asDateInstance(thisValue); 653 double milli = thisDateObj->internalNumber(); 654 if (isnan(milli)) 655 return jsNaN(exec); 656 657 GregorianDateTime t; 658 thisDateObj->msToGregorianDateTime(milli, utc, t); 614 const bool outputIsUTC = false; 615 616 DateInstance* thisDateObj = asDateInstance(thisValue); 617 618 GregorianDateTime t; 619 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 620 return jsNaN(exec); 659 621 return jsNumber(exec, t.monthDay); 660 622 } … … 665 627 return throwError(exec, TypeError); 666 628 667 const bool utc = true; 668 669 DateInstance* thisDateObj = asDateInstance(thisValue); 670 double milli = thisDateObj->internalNumber(); 671 if (isnan(milli)) 672 return jsNaN(exec); 673 674 GregorianDateTime t; 675 thisDateObj->msToGregorianDateTime(milli, utc, t); 629 const bool outputIsUTC = true; 630 631 DateInstance* thisDateObj = asDateInstance(thisValue); 632 633 GregorianDateTime t; 634 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 635 return jsNaN(exec); 676 636 return jsNumber(exec, t.monthDay); 677 637 } … … 682 642 return throwError(exec, TypeError); 683 643 684 const bool utc = false; 685 686 DateInstance* thisDateObj = asDateInstance(thisValue); 687 double milli = thisDateObj->internalNumber(); 688 if (isnan(milli)) 689 return jsNaN(exec); 690 691 GregorianDateTime t; 692 thisDateObj->msToGregorianDateTime(milli, utc, t); 644 const bool outputIsUTC = false; 645 646 DateInstance* thisDateObj = asDateInstance(thisValue); 647 648 GregorianDateTime t; 649 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 650 return jsNaN(exec); 693 651 return jsNumber(exec, t.weekDay); 694 652 } … … 699 657 return throwError(exec, TypeError); 700 658 701 const bool utc = true; 702 703 DateInstance* thisDateObj = asDateInstance(thisValue); 704 double milli = thisDateObj->internalNumber(); 705 if (isnan(milli)) 706 return jsNaN(exec); 707 708 GregorianDateTime t; 709 thisDateObj->msToGregorianDateTime(milli, utc, t); 659 const bool outputIsUTC = true; 660 661 DateInstance* thisDateObj = asDateInstance(thisValue); 662 663 GregorianDateTime t; 664 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 665 return jsNaN(exec); 710 666 return jsNumber(exec, t.weekDay); 711 667 } … … 716 672 return throwError(exec, TypeError); 717 673 718 const bool utc = false; 719 720 DateInstance* thisDateObj = asDateInstance(thisValue); 721 double milli = thisDateObj->internalNumber(); 722 if (isnan(milli)) 723 return jsNaN(exec); 724 725 GregorianDateTime t; 726 thisDateObj->msToGregorianDateTime(milli, utc, t); 674 const bool outputIsUTC = false; 675 676 DateInstance* thisDateObj = asDateInstance(thisValue); 677 678 GregorianDateTime t; 679 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 680 return jsNaN(exec); 727 681 return jsNumber(exec, t.hour); 728 682 } … … 733 687 return throwError(exec, TypeError); 734 688 735 const bool utc = true; 736 737 DateInstance* thisDateObj = asDateInstance(thisValue); 738 double milli = thisDateObj->internalNumber(); 739 if (isnan(milli)) 740 return jsNaN(exec); 741 742 GregorianDateTime t; 743 thisDateObj->msToGregorianDateTime(milli, utc, t); 689 const bool outputIsUTC = true; 690 691 DateInstance* thisDateObj = asDateInstance(thisValue); 692 693 GregorianDateTime t; 694 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 695 return jsNaN(exec); 744 696 return jsNumber(exec, t.hour); 745 697 } … … 750 702 return throwError(exec, TypeError); 751 703 752 const bool utc = false; 753 754 DateInstance* thisDateObj = asDateInstance(thisValue); 755 double milli = thisDateObj->internalNumber(); 756 if (isnan(milli)) 757 return jsNaN(exec); 758 759 GregorianDateTime t; 760 thisDateObj->msToGregorianDateTime(milli, utc, t); 704 const bool outputIsUTC = false; 705 706 DateInstance* thisDateObj = asDateInstance(thisValue); 707 708 GregorianDateTime t; 709 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 710 return jsNaN(exec); 761 711 return jsNumber(exec, t.minute); 762 712 } … … 767 717 return throwError(exec, TypeError); 768 718 769 const bool utc = true; 770 771 DateInstance* thisDateObj = asDateInstance(thisValue); 772 double milli = thisDateObj->internalNumber(); 773 if (isnan(milli)) 774 return jsNaN(exec); 775 776 GregorianDateTime t; 777 thisDateObj->msToGregorianDateTime(milli, utc, t); 719 const bool outputIsUTC = true; 720 721 DateInstance* thisDateObj = asDateInstance(thisValue); 722 723 GregorianDateTime t; 724 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 725 return jsNaN(exec); 778 726 return jsNumber(exec, t.minute); 779 727 } … … 784 732 return throwError(exec, TypeError); 785 733 786 const bool utc = false; 787 788 DateInstance* thisDateObj = asDateInstance(thisValue); 789 double milli = thisDateObj->internalNumber(); 790 if (isnan(milli)) 791 return jsNaN(exec); 792 793 GregorianDateTime t; 794 thisDateObj->msToGregorianDateTime(milli, utc, t); 734 const bool outputIsUTC = false; 735 736 DateInstance* thisDateObj = asDateInstance(thisValue); 737 738 GregorianDateTime t; 739 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 740 return jsNaN(exec); 795 741 return jsNumber(exec, t.second); 796 742 } … … 801 747 return throwError(exec, TypeError); 802 748 803 const bool utc = true; 804 805 DateInstance* thisDateObj = asDateInstance(thisValue); 806 double milli = thisDateObj->internalNumber(); 807 if (isnan(milli)) 808 return jsNaN(exec); 809 810 GregorianDateTime t; 811 thisDateObj->msToGregorianDateTime(milli, utc, t); 749 const bool outputIsUTC = true; 750 751 DateInstance* thisDateObj = asDateInstance(thisValue); 752 753 GregorianDateTime t; 754 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 755 return jsNaN(exec); 812 756 return jsNumber(exec, t.second); 813 757 } … … 848 792 return throwError(exec, TypeError); 849 793 850 const bool utc = false; 851 852 DateInstance* thisDateObj = asDateInstance(thisValue); 853 double milli = thisDateObj->internalNumber(); 854 if (isnan(milli)) 855 return jsNaN(exec); 856 857 GregorianDateTime t; 858 thisDateObj->msToGregorianDateTime(milli, utc, t); 794 const bool outputIsUTC = false; 795 796 DateInstance* thisDateObj = asDateInstance(thisValue); 797 798 GregorianDateTime t; 799 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 800 return jsNaN(exec); 859 801 return jsNumber(exec, -gmtoffset(t) / minutesPerHour); 860 802 } … … 891 833 892 834 GregorianDateTime t; 893 thisDateObj-> msToGregorianDateTime(milli,inputIsUTC, t);835 thisDateObj->getGregorianDateTime(inputIsUTC, t); 894 836 895 837 if (!fillStructuresUsingTimeArgs(exec, args, numArgsToUse, &ms, &t)) { … … 923 865 // Based on ECMA 262 15.9.5.40 - .41 (set[UTC]FullYear) 924 866 // the time must be reset to +0 if it is NaN. 925 thisDateObj->msToGregorianDateTime(0, true, t);867 WTF::msToGregorianDateTime(0, true, t); 926 868 else { 927 869 double secs = floor(milli / msPerSecond); 928 870 ms = milli - secs * msPerSecond; 929 thisDateObj-> msToGregorianDateTime(milli,inputIsUTC, t);871 thisDateObj->getGregorianDateTime(inputIsUTC, t); 930 872 } 931 873 … … 1030 972 return throwError(exec, TypeError); 1031 973 1032 const bool utc= false;974 const bool outputIsUTC = false; 1033 975 1034 976 DateInstance* thisDateObj = asDateInstance(thisValue); … … 1046 988 // Based on ECMA 262 B.2.5 (setYear) 1047 989 // the time must be reset to +0 if it is NaN. 1048 thisDateObj->msToGregorianDateTime(0, true, t);990 WTF::msToGregorianDateTime(0, true, t); 1049 991 else { 1050 992 double secs = floor(milli / msPerSecond); 1051 993 ms = milli - secs * msPerSecond; 1052 thisDateObj-> msToGregorianDateTime(milli, utc, t);994 thisDateObj->getGregorianDateTime(outputIsUTC, t); 1053 995 } 1054 996 … … 1062 1004 1063 1005 t.year = (year > 99 || year < 0) ? year - 1900 : year; 1064 JSValue result = jsNumber(exec, gregorianDateTimeToMS(t, ms, utc));1006 JSValue result = jsNumber(exec, gregorianDateTimeToMS(t, ms, outputIsUTC)); 1065 1007 thisDateObj->setInternalValue(result); 1066 1008 return result; … … 1072 1014 return throwError(exec, TypeError); 1073 1015 1074 const bool utc = false; 1075 1076 DateInstance* thisDateObj = asDateInstance(thisValue); 1077 double milli = thisDateObj->internalNumber(); 1078 if (isnan(milli)) 1079 return jsNaN(exec); 1080 1081 GregorianDateTime t; 1082 thisDateObj->msToGregorianDateTime(milli, utc, t); 1016 const bool outputIsUTC = false; 1017 1018 DateInstance* thisDateObj = asDateInstance(thisValue); 1019 1020 GregorianDateTime t; 1021 if (!thisDateObj->getGregorianDateTime(outputIsUTC, t)) 1022 return jsNaN(exec); 1083 1023 1084 1024 // NOTE: IE returns the full year even in getYear.
Note:
See TracChangeset
for help on using the changeset viewer.