<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>3381</bug_id>
          
          <creation_ts>2005-06-09 07:01:17 -0700</creation_ts>
          <short_desc>Date.prototype.setDate() incorrect for values &gt;=128</short_desc>
          <delta_ts>2005-08-07 12:56:50 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>412</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.4</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>3759</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Gavin Kistner">gavin</reporter>
          <assigned_to name="Geoffrey Garen">ggaren</assigned_to>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>11159</commentid>
    <comment_count>0</comment_count>
    <who name="Gavin Kistner">gavin</who>
    <bug_when>2005-06-09 07:01:21 -0700</bug_when>
    <thetext>var d = new Date;
var out = &quot;Today: &quot; + d + &quot;\n&quot;;
d.setDate( d.getDate() + 280 )
out += &quot;Future: &quot; + d;

Should result in a date 280 days in the future. This works on Firefox and IE:
   Today: Thu Jun 09 2005 07:59:31 GMT-0600 (MDT)
   Future: Thu Mar 16 2006 07:59:31 GMT-0700 (MST)

but fails on the latest version of Safari (2.0.412):
   Today: Thu Jun 09 2005 08:00:45 GMT-0600
   Future: Sun Jul 03 2005 08:00:45 GMT-0600</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>11659</commentid>
    <comment_count>1</comment_count>
    <who name="Gavin Kistner">gavin</who>
    <bug_when>2005-06-12 17:21:11 -0700</bug_when>
    <thetext>The failure seems to be with date values greater than 127. 

This test code:
  var out = &apos;&apos;;
  for ( var i=1; i&lt;300; ++i )
  {
    var theDate = new Date;
    var theValue = theDate.getDate( ) + i;
    theDate.setDate( theValue );
    out += theValue + &apos;::&apos; + theDate + &apos;\n&apos;;
  }

produces the following output (values from 1..120 are contiguous from the current date):

121::Thu Sep 29 2005 18:19:59 GMT-0600
122::Fri Sep 30 2005 18:19:59 GMT-0600
123::Sat Oct 01 2005 18:19:59 GMT-0600
124::Sun Oct 02 2005 18:19:59 GMT-0600
125::Mon Oct 03 2005 18:19:59 GMT-0600
126::Tue Oct 04 2005 18:19:59 GMT-0600
127::Wed Oct 05 2005 18:19:59 GMT-0600
128::Sun Jan 23 2005 18:19:59 GMT-0700
129::Mon Jan 24 2005 18:19:59 GMT-0700
130::Tue Jan 25 2005 18:19:59 GMT-0700
131::Wed Jan 26 2005 18:19:59 GMT-0700
132::Thu Jan 27 2005 18:19:59 GMT-0700
133::Fri Jan 28 2005 18:19:59 GMT-0700
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>15103</commentid>
    <comment_count>2</comment_count>
      <attachid>3067</attachid>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2005-07-23 11:43:27 -0700</bug_when>
    <thetext>Created attachment 3067
Patch

The problem is overflow. CFGregorianDate is only an 8-bit signed value. This
patch fixes setDate, but setMonth, setYear, and setFullYear still have the same
problem.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>15104</commentid>
    <comment_count>3</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2005-07-23 11:46:33 -0700</bug_when>
    <thetext>(In reply to comment #2)

[ Should read: }

In CFGregorianDate, month, day, hour, and minute are 8-bit signed values. SetMonth still has the same 
problem.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>15173</commentid>
    <comment_count>4</comment_count>
      <attachid>3067</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2005-07-25 11:56:22 -0700</bug_when>
    <thetext>Comment on attachment 3067
Patch

Looks good, r=me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>16117</commentid>
    <comment_count>5</comment_count>
    <who name="William Coldwell (Cryo)">cryo</who>
    <bug_when>2005-08-07 10:04:01 -0700</bug_when>
    <thetext>For some reason the code is thinking my current date is epoch instead of Sun Aug  7 13:02:14 EDT 
2005 so the check fails because the year is wrong?

This test checks for regression against: 3381 Date.prototype.setDate() incorrect for values &gt;=128.

If the test passes, all the dates below will be sequential.

setDate(120): Mon Mar 30 1970 19:00:00 GMT-0500
setDate(121): Tue Mar 31 1970 19:00:00 GMT-0500
setDate(122): Wed Apr 01 1970 19:00:00 GMT-0500
setDate(123): Thu Apr 02 1970 19:00:00 GMT-0500
setDate(124): Fri Apr 03 1970 19:00:00 GMT-0500
setDate(125): Sat Apr 04 1970 19:00:00 GMT-0500
setDate(126): Sun Apr 05 1970 19:00:00 GMT-0500
setDate(127): Mon Apr 06 1970 19:00:00 GMT-0500
setDate(128): Tue Apr 07 1970 19:00:00 GMT-0500
setDate(129): Wed Apr 08 1970 19:00:00 GMT-0500</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>16126</commentid>
    <comment_count>6</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2005-08-07 12:56:50 -0700</bug_when>
    <thetext>The output doesn&apos;t look like a failure -- all the dates are sequential, as they should be.

The test also has nothing to do with your current date. The year should be 1970, since the constructor call 
is new Date(0). Subsequently, setDate(120) gives the 120th day in 1970, which is Mar 30.

This test also doesn&apos;t fail when I execute run-webkit-tests.

Changing resolution to FIXED.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>3067</attachid>
            <date>2005-07-23 11:43:27 -0700</date>
            <delta_ts>2005-07-25 11:56:22 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>MakeDatePatch.txt</filename>
            <type>text/plain</type>
            <size>621</size>
            <attacher name="Geoffrey Garen">ggaren</attacher>
            
              <data encoding="base64">SW5kZXg6IGtqcy9kYXRlX29iamVjdC5jcHAKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQpSQ1MgZmlsZTogL2N2cy9yb290
L0phdmFTY3JpcHRDb3JlL2tqcy9kYXRlX29iamVjdC5jcHAsdgpyZXRyaWV2aW5nIHJldmlzaW9u
IDEuNDQKZGlmZiAtdSAtcjEuNDQgZGF0ZV9vYmplY3QuY3BwCi0tLSBranMvZGF0ZV9vYmplY3Qu
Y3BwCTIzIEp1bCAyMDA1IDAwOjUwOjM2IC0wMDAwCTEuNDQKKysrIGtqcy9kYXRlX29iamVjdC5j
cHAJMjMgSnVsIDIwMDUgMTg6NDE6MjIgLTAwMDAKQEAgLTcxMCw4ICs3MTAsOSBAQAogICAgICAg
bXMgPSBhcmdzWzNdLnRvSW50MzIoZXhlYyk7CiAgICAgYnJlYWs7CiAgIGNhc2UgU2V0RGF0ZToK
LSAgICB0LT50bV9tZGF5ID0gYXJnc1swXS50b0ludDMyKGV4ZWMpOwotICAgIGJyZWFrOworICAg
ICAgdC0+dG1fbWRheSA9IDA7CisgICAgICBtcyArPSBhcmdzWzBdLnRvSW50MzIoZXhlYykgKiBt
c1BlckRheTsKKyAgICAgIGJyZWFrOwogICBjYXNlIFNldE1vbnRoOgogICAgIHQtPnRtX21vbiA9
IGFyZ3NbMF0udG9JbnQzMihleGVjKTsKICAgICBpZiAoYXJncy5zaXplKCkgPj0gMikK
</data>
<flag name="review"
          id="270"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>