From: merch-redmine@... Date: 2019-10-07T17:07:47+00:00 Subject: [ruby-core:95261] [Ruby master Feature#16244] Add a Time#before? and Time#after? method 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/ Unsubscribe: