[#92063] [Ruby trunk Misc#15723] Reconsider numbered parameters — zverok.offline@...
Issue #15723 has been updated by zverok (Victor Shepelev).
3 messages
2019/03/31
[ruby-core:91945] [Ruby trunk Bug#15712] DateTime#=== should be defined and compare date and time instead of just the date
From:
localhostdotdev@...
Date:
2019-03-22 17:34:04 UTC
List:
ruby-core #91945
Issue #15712 has been updated by localhostdotdev (localhost .dev).
@nobu That's weird, actually original blog posts says "true" for === (like you), and I get "false" on ruby-head, ruby-2.5.3, ruby-2.6.1, and ruby-2.6.2.
e.g.
```
$ rvm ruby-head do ruby -e 'require "date"; dt1 = DateTime.new(2001, 2, 3); dt2 = DateTime.new(2001, 2, 3, 12); puts "=== #{dt1 == dt2}"; puts "== #{dt1 == dt2 }"; puts RUBY_VERSION'
=== false
== false
2.7.0
$ ...
=== false
== false
2.5.3
$ ...
=== false
== false
2.6.2
```
(I tried setting the timezone but same result)
ruby-head: `ruby 2.7.0dev (2019-03-18 trunk 67296) [x86_64-darwin17]`
But when running in irb (RUBY_VERSION 2.7.0), I get "true" for === (like the original blog post and you).
`DateTime.new.method(:===).source` sadly doesn't work so I don't know what's going on.
(I tried searching for gems that override the `===` method but couldn't find any: `ag "class DateTime" | grep -v test_ | grep -v "<" | ruby -ne "puts File.read(\$_.split(':').first).lines.map { |l| \$_.split(':').first + l }" | grep "==="`)
(I sometimes got `true` but not sure how)
I'm not sure how I would continue debugging that except re-compiling my own version of ruby).
----------------------------------------
Bug #15712: DateTime#=== should be defined and compare date and time instead of just the date
https://bugs.ruby-lang.org/issues/15712#change-77277
* Author: localhostdotdev (localhost .dev)
* Status: Feedback
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.7.0dev (2019-03-18 trunk 67296) [x86_64-darwin17]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
DateTime#=== is inherited from Date#=== without overwriting the #=== method, this leads to DateTime#=== comparing only dates and ignore the time part.
```
DateTime.new(2001, 2, 3) === DateTime.new(2001, 2, 3, 12)
=> false
```
I think this is not the expected behavior but existing code might rely on this.
Date#===: https://ruby-doc.org/stdlib-2.1.9/libdoc/date/rdoc/Date.html#method-i-3D-3D-3D
Source: https://medium.com/@dvandersluis/an-rspec-time-issue-and-its-not-about-timezones-a89bbd167b86
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>