From: shevegen@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:96383] [Ruby master Bug#16440] Date range inclusion behaviors are inconsistent
Date: Sat, 21 Dec 2019 03:51:08 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-83306.20191221035107.77546d1d571a33f9@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-16440.20191220162254@ruby-lang.org
Issue #16440 has been updated by shevegen (Robert A. Heiler).
I have no strong opinion either way but I can understand the
assumption by st0012 to some extent. For example, I personally
always seem to think more about .include? than .cover?, largely
because I simply use .include? a lot more. I once even added
some .partial_include? method to Enumerable (or somewhere else,
I don't remember ... was years ago).
The other thing is DateTime, Date, and Time. Personally I'd love
if we could have just one-ring-to-rule-them-all one day, perhaps
in ruby 4.0 or so - I think that is a partial complaint by Stan,
in the sense of the behaviour he showed (but I am assuming this
here). But again, I have no real strong opinion either way.
Would be interesting to ask Stan Lo whether he knew about
.cover? or not. :)
----------------------------------------
Bug #16440: Date range inclusion behaviors are inconsistent
https://bugs.ruby-lang.org/issues/16440#change-83306
* Author: st0012 (Stan Lo)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
It's weird that a Date range can include Time and DateTime objects that were converted from a Date object. But it can't include a newly generated DateTime object. For example:
```
may1 = Date.parse("2019-05-01")
may3 = Date.parse("2019-05-03")
noon_of_may3 = DateTime.parse("2019-05-03 12:00")
may31 = Date.parse("2019-05-31")
(may1..may31).include? may3 # => True
(may1..may31).include? may3.to_time # => True
(may1..may31).include? may3.to_datetime # => True
(may1..may31).include? noon_of_may3 # => False
```
Shouldn't the last case return `true` as well?
Related Rails issue: https://github.com/rails/rails/issues/36175
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2019-12-21 3:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-16440.20191220162254@ruby-lang.org>
2019-12-20 16:22 ` [ruby-core:96377] [Ruby master Bug#16440] Date range inclusion behaviors are inconsistent stan001212
2019-12-20 17:28 ` [ruby-core:96378] " wishdev
2019-12-20 17:55 ` [ruby-core:96379] " zverok.offline
2019-12-21 3:51 ` shevegen [this message]
2019-12-21 15:05 ` [ruby-core:96389] " stan001212
2019-12-21 15:25 ` [ruby-core:96390] " zverok.offline
2019-12-29 19:10 ` [ruby-core:96581] " merch-redmine
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-83306.20191221035107.77546d1d571a33f9@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).