Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a duration and remaining time method to the Talk model.

  • Loading branch information...
commit c63a667499bc9c26d7025bf1622eadceac97c81a 1 parent 77d6aee
@chrisdarroch authored
Showing with 10 additions and 0 deletions.
  1. +10 −0 app/models/talk.rb
View
10 app/models/talk.rb
@@ -21,6 +21,16 @@ def self.for_venue(venue)
def day
start_at.to_date
end
+
+ def duration
+ end_at - start_at
+ end
+
+ def remaining
+ remnants = end_at - Time.now
+ remnants = [duration, remnants].min # To cap it at the talk's length
+ [0, remnants].max # So that we don't end up with a negative time if it's in the past.
+ end
private
Please sign in to comment.
Something went wrong with that request. Please try again.