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=-2.7 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=no 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 EB8691F4BD for ; Mon, 7 Oct 2019 23:35:06 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 0F9C0120A2C; Tue, 8 Oct 2019 08:34:57 +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 2F9B4120A2B for ; Tue, 8 Oct 2019 08:34:55 +0900 (JST) Received: by filter0096p3iad2.sendgrid.net with SMTP id filter0096p3iad2-27269-5D9BCB9F-64 2019-10-07 23:34:55.866303725 +0000 UTC m=+527606.233753565 Received: from herokuapp.com (unknown [54.158.92.1]) by ismtpd0073p1mdw1.sendgrid.net (SG) with ESMTP id 8GZ4hY6PQmSLzWISiIXZtw for ; Mon, 07 Oct 2019 23:34:55.626 +0000 (UTC) Date: Mon, 07 Oct 2019 23:34:55 +0000 (UTC) From: sawadatsuyoshi@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 70860 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16244 X-Redmine-Issue-Author: stevendaniels X-Redmine-Sender: sawa 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?jFXA8Rt481sXUUIO9tYW1AJlMOZdNdlSw=2F5TfLCefGvaumrWrHnSNk5MEDujM=2F?= =?us-ascii?Q?jb92siplyEisXrkTdk4cVUg4u7NKNEpvsmz6rkb?= =?us-ascii?Q?t5CQ6xhw06OXyPZeWbmVlpauFH24fCwZWazi5PL?= =?us-ascii?Q?xAh4SW0An7yzRaJvzIgQBJZ4VwJyJLyhDZFq8bA?= =?us-ascii?Q?1g7+m+htuDqMPb5S3L=2FpWCjxJilJ=2FFVLBzw=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95273 Subject: [ruby-core:95273] [Ruby master Feature#16244] Add a Time#before? and Time#after? method 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 #16244 has been updated by sawa (Tsuyoshi Sawada). Jeremy Evans is right about this. But I agree that your second example ``` birthday > thirteen_years_ago ``` is a bit hard to comprehend. However, ``` birthday.after? thirteen_years_ago ``` is as hard to comprehend. You should not be writing like that. You should either do somthing like ``` birthday + thirteen_years > now ``` or ``` now - birthday < thirteen_years ``` ---------------------------------------- Feature #16244: Add a Time#before? and Time#after? method https://bugs.ruby-lang.org/issues/16244#change-81949 * Author: stevendaniels (Steven Daniels) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- Comparing times using `>` and`<` can be pretty confusing. I'd like to propose `Time#before?` and `Time#after?` methods for aliasing `Time#<` and `Time#>` These method aliases would make the code more readable. :) Current syntax: ``` ruby if current_time < expiration_at # do stuff end if birthday > thirteen_years_ago # you need a parent's permission to sign up end ``` What I'd like to see added: ``` ruby if current_time.before? expiration_at # do stuff end if birthday.after? thirteen_years_ago # you need a parent's permission to sign up end ``` Thanks for your consideration! -- https://bugs.ruby-lang.org/