Project

General

Profile

Actions

Feature #16244

open

Add a Time#before? and Time#after? method

Added by stevendaniels (Steven Daniels) about 5 years ago. Updated almost 5 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:95260]

Description

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:

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:

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!

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0