Issue #16244 has been updated by anastasiastowers (Anastasia Stowers).


Using the > and < symbols makes sense to compare Time only with the knowledge of the underlying unix time system being used.

Although this is the way that we choose to store values of it in our systems, Time is special because it has direction in the way that we perceive it. The words °»before°… and °»after°… the only words we use to compare it when considering infinitesimally close event values.

I think the promotion of °»natural language°… is the direction that Ruby has been going.

Some examples of preferring °»natural language°…:
https://bugs.ruby-lang.org/issues/12746
https://bugs.ruby-lang.org/issues/13784
https://bugs.ruby-lang.org/issues/14043
https://bugs.ruby-lang.org/issues/14697

----------------------------------------
Feature #16244: Add a Time#before? and Time#after? method
https://bugs.ruby-lang.org/issues/16244#change-83113

* 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: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>