<?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>283825</bug_id>
          
          <creation_ts>2024-11-29 06:10:20 -0800</creation_ts>
          <short_desc>non standard new Date(&apos;2024-12-3&apos;) yields to Invalid Date</short_desc>
          <delta_ts>2025-08-26 18:34:14 -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>WebKit Nightly Build</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=241103</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=223166</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Sebastian Schlatow">buzzdee</reporter>
          <assigned_to name="Keita Nonaka">iKonnyaku40</assigned_to>
          <cc>buzzdee</cc>
    
    <cc>karlcow</cc>
    
    <cc>rechdshraipfelehr</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2078164</commentid>
    <comment_count>0</comment_count>
    <who name="Sebastian Schlatow">buzzdee</who>
    <bug_when>2024-11-29 06:10:20 -0800</bug_when>
    <thetext>new Date(&apos;2024-12-3&apos;) yields to: Invalid Date

Date.parse(&apos;2024-12-3&apos;) yields to: NaN

Firefox:

new Date(&apos;2024-12-3&apos;) yields to: Date Tue Dec 03 2024 00:00:00 GMT+0100 (Central European Standard Time)

Date.parse(&apos;2024-12-3&apos;) yields to: 1733180400000

Chromium:

new Date(&apos;2024-12-3&apos;) yields to: Tue Dec 03 2024 00:00:00 GMT+0100 (Central European Standard Time)

Date.parse(&apos;2024-12-3&apos;) yields to: 1733180400000</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2078393</commentid>
    <comment_count>1</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-12-01 19:19:58 -0800</bug_when>
    <thetext>&gt; the value produced by this function is implementation-defined when given any String value that does not conform to the Date Time String Format (21.4.1.32) and that could not be produced in that implementation by the toString or toUTCString method.

While this leads to an identical result in Firefox and Chrome. 
Per sec this is an implementation defined format. 

https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date-time-string-format

@Sebastian,

did you notice a website breaking because of this?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2078394</commentid>
    <comment_count>2</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-12-01 19:20:56 -0800</bug_when>
    <thetext>The valid format per spec is `YYYY-MM-DDTHH:mm:ss.sssZ` or a truncation of it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2078501</commentid>
    <comment_count>3</comment_count>
    <who name="Sebastian Schlatow">buzzdee</who>
    <bug_when>2024-12-02 07:13:43 -0800</bug_when>
    <thetext>&gt; did you notice a website breaking because of this?

@Karl yes, our inhouse webapp, but we found a work around ;)

But nonetheless it would be great if it were more robust.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2079630</commentid>
    <comment_count>4</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-12-06 06:11:13 -0800</bug_when>
    <thetext>&lt;rdar://problem/141044926&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2080031</commentid>
    <comment_count>5</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-12-08 17:29:24 -0800</bug_when>
    <thetext>Bug 223166 is the bug for the implementation of Temporal.
It doesn&apos;t fix this specific issue, but it helps figure out the priorities. 
It would be interesting to dig if there have been more compat issues reported because of this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2080041</commentid>
    <comment_count>6</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-12-08 17:38:24 -0800</bug_when>
    <thetext>The code might be here. 
https://searchfox.org/wubkat/rev/52d16c972a163b36fe64a99efb66af93c6e2f2b2/Source/WTF/wtf/DateMath.cpp#728-762</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2080042</commentid>
    <comment_count>7</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-12-08 17:39:51 -0800</bug_when>
    <thetext>ha no, this was for &quot;2024/12/03&quot;.
The standard parsing with dashese is at 
https://searchfox.org/wubkat/rev/52d16c972a163b36fe64a99efb66af93c6e2f2b2/Source/WTF/wtf/DateMath.cpp#616-673</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2080043</commentid>
    <comment_count>8</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2024-12-08 17:44:33 -0800</bug_when>
    <thetext>which calls parseES5DatePortion(std::span&lt;const LChar&gt;&amp; currentPosition, int&amp; year, long&amp; month, long&amp; day)
https://searchfox.org/wubkat/rev/52d16c972a163b36fe64a99efb66af93c6e2f2b2/Source/WTF/wtf/DateMath.cpp#448-490</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2102198</commentid>
    <comment_count>9</comment_count>
    <who name="">rechdshraipfelehr</who>
    <bug_when>2025-03-11 05:59:47 -0700</bug_when>
    <thetext>I guess many people are running into this issue as it works in the other browsers and it should work according to spec. There are also many reports and questions online, like on StackOverflow, where this post from 2010 is, I think, the most popular of these posts, with 256k views: https://stackoverflow.com/questions/4310953/invalid-date-in-safari

Here is an interesting use case, as the value of an input type=&quot;date&quot; is in the format YYYY-MM-DD: https://stackoverflow.com/questions/3085937/safari-js-cannot-parse-yyyy-mm-dd-date-format</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2102435</commentid>
    <comment_count>10</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2025-03-11 19:41:05 -0700</bug_when>
    <thetext>&gt;  as it works in the other browsers and it should work according to spec

See above. The spec says:

DD	is the day of the month as two decimal digits from 01 to 31.

So this is not defined in the spec. In the spec there is sometimes the mention &quot;Implementation-defined&quot; which is also areas which are NOT defined by the spec. Just to be clear. :) 

But I didn&apos;t close the bug too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2102437</commentid>
    <comment_count>11</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2025-03-11 19:47:13 -0700</bug_when>
    <thetext>What about months?

2024-1-3</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2102468</commentid>
    <comment_count>12</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2025-03-11 21:49:08 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/42306</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2102875</commentid>
    <comment_count>13</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2025-03-13 05:27:09 -0700</bug_when>
    <thetext>Firefox, Chrome

Date.parse(&quot;2025-03-01T00:00:00Z&quot;)
1740787200000
Date.parse(&quot;2025-03-01T00:00:00&quot;)
1740754800000
Date.parse(&quot;2025-03-01&quot;)
1740787200000
Date.parse(&quot;2025-03-1&quot;)
1740754800000
Date.parse(&quot;2025-3-01&quot;)
1740754800000
Date.parse(&quot;2025-3-1&quot;)
1740754800000 
new Date(&quot;2025-03-01&quot;)
Sat Mar 01 2025 09:00:00 GMT+0900 (Japan Standard Time)
new Date(&quot;2025-03-1&quot;)
Sat Mar 01 2025 00:00:00 GMT+0900 (Japan Standard Time)


I just realized that 
Date.parse(&quot;2025-03-1&quot;) !== Date.parse(&quot;2025-03-01&quot;)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2102877</commentid>
    <comment_count>14</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2025-03-13 05:36:44 -0700</bug_when>
    <thetext>OK my patch is not working yet the same way that Firefox and Chrome are working. 
I wonder why they chose this implementation. 
It&apos;s quite problematic. 


&gt; Date.parse(&quot;2025-03-01T00:00:00Z&quot;)
&lt; 1740787200000

&gt; Date.parse(&quot;2025-03-01T00:00:00&quot;)
&lt; 1740754800000

&gt; Date.parse(&quot;2025-03-01&quot;)
&lt; 1740787200000

&gt; Date.parse(&quot;2025-03-1&quot;)
&lt; 1740787200000

&gt; Date.parse(&quot;2025-3-01&quot;)
&lt; 1740787200000

&gt; Date.parse(&quot;2025-3-1&quot;)
&lt; 1740787200000

&gt; new Date(&quot;2025-03-01&quot;)
&lt; Sat Mar 01 2025 09:00:00 GMT+0900 (Japan Standard Time)

&gt; new Date(&quot;2025-03-1&quot;)
&lt; Sat Mar 01 2025 09:00:00 GMT+0900 (Japan Standard Time)

&gt; new Date(&quot;2025-3-1&quot;)
&lt; Sat Mar 01 2025 09:00:00 GMT+0900 (Japan Standard Time)

&gt; new Date(&quot;2025-3-01&quot;)
&lt; Sat Mar 01 2025 09:00:00 GMT+0900 (Japan Standard Time)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2103679</commentid>
    <comment_count>15</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2025-03-16 19:19:01 -0700</bug_when>
    <thetext>More insanity 
https://codepen.io/webcompat/full/QwWOYjY</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2136996</commentid>
    <comment_count>16</comment_count>
    <who name="Keita Nonaka">iKonnyaku40</who>
    <bug_when>2025-08-16 12:38:49 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/49500</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2138950</commentid>
    <comment_count>17</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-08-26 18:34:12 -0700</bug_when>
    <thetext>Committed 299182@main (82a3a3991176): &lt;https://commits.webkit.org/299182@main&gt;

Reviewed commits have been landed. Closing PR #49500 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>