class Time
def seconds_until_end_of_day
Time.new(2012, 8, 29, 12, 34, 56).seconds_until_end_of_day # => 41103
Time.new(2012, 8, 29, 0, 0, 0).seconds_until_end_of_day # => 86399
Returns the number of seconds until 23:59:59.
def seconds_until_end_of_day end_of_day.to_i - to_i end