https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112012-02-09T06:09:41ZRuby Issue Tracking SystemRuby master - Bug #5988: Time class interprets "2012-02-30" as "2012-03-01"https://bugs.ruby-lang.org/issues/5988?journal_id=236482012-02-09T06:09:41Zdmarkow (Dylan Markow)dmarkow@gmail.com
<ul></ul><p>=begin<br>
By comparison, the Date class handles this properly:</p>
<p>irb(main):004:0> Date.new 2012, 2, 29<br>
=> #<Date: 2012-02-29 ((2455987j,0s,0n),+0s,2299161j)><br>
irb(main):005:0> Date.new 2012, 2, 30<br>
ArgumentError: invalid date<br>
from (irb):5:in <code>new' from (irb):5 from /Users/dylan/.rbenv/versions/2.0.0-dev/bin/irb:12:in </code>'<br>
irb(main):006:0><br>
=end</p> Ruby master - Bug #5988: Time class interprets "2012-02-30" as "2012-03-01"https://bugs.ruby-lang.org/issues/5988?journal_id=236642012-02-10T02:26:12Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>akr (Akira Tanaka)</i></li></ul> Ruby master - Bug #5988: Time class interprets "2012-02-30" as "2012-03-01"https://bugs.ruby-lang.org/issues/5988?journal_id=236732012-02-10T09:29:08Zakr (Akira Tanaka)akr@fsij.org
<ul></ul><p>2012/2/10 Yui NARUSE <a href="mailto:naruse@airemix.jp" class="email">naruse@airemix.jp</a>:</p>
<blockquote>
<p>The time class seems to accept any number from 1-31 as a valid day for any month of the year, even if the month has less than 31 days. If the day exceeds the number of days, it just spills over into the following month; "2012-02-30" become "2012-03-01", "2012-04-31" becomes "2012-05-01", and so on. It's not until you try 32 as a day number that you get the expected Argument Error. This happens with Time.new, Time.parse, Time.local, Time.utc, etc.</p>
</blockquote>
<p>Once, we tried to check time validity by testing round tripness.<br>
<a href="https://blade.ruby-lang.org/ruby-core/14517">[ruby-core:14517]</a></p>
<p>But it was too strict. So we abondon the test.<br>
<a href="https://blade.ruby-lang.org/ruby-dev/33086">[ruby-dev:33086]</a></p>
<h2>If people really need strict Time constructors,<br>
new methods (Time.strict_local, Time.strict_utc, etc.) should be considerd.</h2>
<p>Tanaka Akira</p> Ruby master - Bug #5988: Time class interprets "2012-02-30" as "2012-03-01"https://bugs.ruby-lang.org/issues/5988?journal_id=382222013-04-04T23:41:07Zakr (Akira Tanaka)akr@fsij.org
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Rejected</i></li></ul><p>No reply after explanation long time.</p>