Issue #16244 has been updated by nobu (Nobuyoshi Nakada).


anastasiastowers (Anastasia Stowers) wrote:
> Using the > and < symbols makes sense to compare Time only with the knowledge of the underlying unix time system being used.

I don°«t think that knowledge necessary.
Rather, the time is comparable physical quantity.

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

These are selections of more proper names.

> https://bugs.ruby-lang.org/issues/14043

This is a deprecation of too magical special variables.

> https://bugs.ruby-lang.org/issues/14697

This is opposite, preferring a symbol over °»natural language°….

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

* 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>