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.8 required=3.0 tests=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 22D941F4BE for ; Mon, 7 Oct 2019 19:43:51 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id E6C0F1209E6; Tue, 8 Oct 2019 04:43:40 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id DB1981209E2 for ; Tue, 8 Oct 2019 04:43:38 +0900 (JST) Received: by filter0095p3las1.sendgrid.net with SMTP id filter0095p3las1-759-5D9B956B-25 2019-10-07 19:43:39.291251273 +0000 UTC m=+10769.014637067 Received: from herokuapp.com (unknown [54.158.92.1]) by ismtpd0067p1mdw1.sendgrid.net (SG) with ESMTP id E_iNtoXlSF6qGv0OT4lnEQ for ; Mon, 07 Oct 2019 19:43:39.113 +0000 (UTC) Date: Mon, 07 Oct 2019 19:43:39 +0000 (UTC) From: stevendaniels88@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 70850 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16244 X-Redmine-Issue-Author: stevendaniels X-Redmine-Sender: stevendaniels 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?wmILHqzqLVzb3UFOeitWvWAgTOPWggHIH6J4WQp2V6V5ueXD8CiUsFF1+PgrVA?= =?us-ascii?Q?wJUA6KG0Rs7uhO+NHniSOcc4o=2F75z9Lr=2Fhmi3xy?= =?us-ascii?Q?4+UB=2FBnVFW1BAfmgY9AxQFY9akvBIidHWtFfiw+?= =?us-ascii?Q?7rL=2F8qEayr3LKFk+EP2JritPaUn+2vyfNy43dxA?= =?us-ascii?Q?IjwBcc2=2FjIIANtVajKTaWJObM4Svaw2nxfg=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95263 Subject: [ruby-core:95263] [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 stevendaniels (Steven Daniels). jeremyevans0 (Jeremy Evans) wrote: > I would guess the `>` and `<` symbols are probably more understandable to people whose native language is not English, at least. It's hard to speak for all non-native English speakers one way or the other, but in the languages non-English languages I speak, using **greater than** and **less than** to compare times isn't a natural way to frame the comparison; by comparison, before and after is a natural way to compare times in most languages. Over the years I've seen this confusion manifested by developers of all levels of experience leading to real life bugs. Adding aliases that help to alleviate that confusion would be a nice thing to provide to all Ruby developers (which is why I'm making this feature request). Subjectively speaking, comparisons like`if blog.published_at.before? Time.now` feel more natural than `if blog.published_at < Time.now`. (Big fan of your work, BTW!) ---------------------------------------- Feature #16244: Add a Time#before? and Time#after? method https://bugs.ruby-lang.org/issues/16244#change-81940 * 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/