From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 0772A1F463 for ; Sun, 29 Dec 2019 19:11:09 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 4EAC4120BA8; Mon, 30 Dec 2019 04:10:55 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id E71C3120BA6 for ; Mon, 30 Dec 2019 04:10:52 +0900 (JST) Received: by filterdrecv-p3las1-5bf99c48d-z5dx7 with SMTP id filterdrecv-p3las1-5bf99c48d-z5dx7-18-5E08FA42-41 2019-12-29 19:10:58.885101791 +0000 UTC m=+1103114.838484051 Received: from herokuapp.com (unknown [54.145.162.235]) by ismtpd0046p1iad2.sendgrid.net (SG) with ESMTP id lmBGu-YwQ92iG4FYB0teGw for ; Sun, 29 Dec 2019 19:10:58.780 +0000 (UTC) Date: Sun, 29 Dec 2019 19:10:58 +0000 (UTC) From: merch-redmine@jeremyevans.net Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 72244 X-Redmine-Project: ruby-master X-Redmine-Issue-Id: 16440 X-Redmine-Issue-Author: st0012 X-Redmine-Sender: jeremyevans0 X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?RVE3t853K5scBhbmJHUzZTFFeVC=2FZSUmHZ0Dc+26wcEi2CTgsF1oz0wTSSxGGN?= =?us-ascii?Q?BID8XiduSJgXfJK2wud1mUHo9zMGStfjSn4OTUB?= =?us-ascii?Q?pVpDLdz2SuV=2FUFGIfK+5bcnpb0p3S2rTfTKe1MX?= =?us-ascii?Q?NVsjNpYUGmH9yhzrxXreiO9XGtAnZRz8WQ89oos?= =?us-ascii?Q?4WRTth5s3m5QIPfdaxhv8BsUNtqXI2MdFSWqZGb?= =?us-ascii?Q?usSUlnA7MzWdPvngo=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 96581 Subject: [ruby-core:96581] [Ruby master Bug#16440] Date range inclusion behaviors are inconsistent X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #16440 has been updated by jeremyevans0 (Jeremy Evans). Status changed from Open to Rejected As explained in some previous comments, if you want to check if a value is on or after the beginning of the range and on or before the end of the range, use `cover?`. `include?` should only be used if you want to check the argument is one of the members of the range (i.e. included in the array returned by `to_a`). ---------------------------------------- Bug #16440: Date range inclusion behaviors are inconsistent https://bugs.ruby-lang.org/issues/16440#change-83546 * Author: st0012 (Stan Lo) * Status: Rejected * 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/