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 EF3ED1F4BE for ; Mon, 7 Oct 2019 17:07:56 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 75DE51209D7; Tue, 8 Oct 2019 02:07:47 +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 3098F1209D1 for ; Tue, 8 Oct 2019 02:07:44 +0900 (JST) Received: by filter0163p3mdw1.sendgrid.net with SMTP id filter0163p3mdw1-11344-5D9B70E3-3 2019-10-07 17:07:47.031041492 +0000 UTC m=+907.846013576 Received: from herokuapp.com (unknown [54.158.92.1]) by ismtpd0053p1iad2.sendgrid.net (SG) with ESMTP id mVu0Tj1SSBqUC-JEym0fKw for ; Mon, 07 Oct 2019 17:07:47.017 +0000 (UTC) Date: Mon, 07 Oct 2019 17:07:47 +0000 (UTC) From: merch-redmine@jeremyevans.net Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 70848 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16244 X-Redmine-Issue-Author: stevendaniels 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?BIu1rdP6IeNXoxXZ=2F80l44JBYrEHt+4UX7fPTHv?= =?us-ascii?Q?7WIK6laeV235ip9qxI=2FlhavYDxlVSDhO=2FFElAUo?= =?us-ascii?Q?+1l7yhh+D1HqfLmTztcwju0vV1LS0QcA4xlN9AO?= =?us-ascii?Q?C7vvuQOQSDOZj=2FoEfW2LoFFBYu0nRLJe5HQ=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95261 Subject: [ruby-core:95261] [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 jeremyevans0 (Jeremy Evans). stevendaniels (Steven Daniels) wrote: > Comparing times using `>` and`<` can be pretty confusing. This is subjective. I don't find such Time comparisons confusing. I would guess the `>` and `<` symbols are probably more understandable to people whose native language is not English, at least. > I'd like to propose `Time#before?` and `Time#after?` methods for aliasing `Time#<` and `Time#>` The argument you are making for adding them could be made for any objects implementing `>` and `<`. Maybe your need could be solved with?: ```ruby module Comparable alias before? < alias after? > end ``` One of the great things about Ruby is that it is simple to add these aliases yourself. ---------------------------------------- Feature #16244: Add a Time#before? and Time#after? method https://bugs.ruby-lang.org/issues/16244#change-81938 * 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/