Skip to content

Commit

Permalink
Remove duplication from date_time calculations
Browse files Browse the repository at this point in the history
Methods: :past? and :future? are already defined identically
in date_and_time/calculations.rb which is included in Date.
Because DateTime is a subclass of Date, it can call them.
  • Loading branch information
gzohari committed Jul 31, 2013
1 parent ffb680e commit 89060b8
Showing 1 changed file with 0 additions and 10 deletions.
Expand Up @@ -10,16 +10,6 @@ def current
end end
end end


# Tells whether the DateTime object's datetime lies in the past.
def past?
self < ::DateTime.current
end

# Tells whether the DateTime object's datetime lies in the future.
def future?
self > ::DateTime.current
end

# Seconds since midnight: DateTime.now.seconds_since_midnight. # Seconds since midnight: DateTime.now.seconds_since_midnight.
def seconds_since_midnight def seconds_since_midnight
sec + (min * 60) + (hour * 3600) sec + (min * 60) + (hour * 3600)
Expand Down

0 comments on commit 89060b8

Please sign in to comment.