diff --git a/stoptime.rb b/stoptime.rb index f8b1c79..7221dd7 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -349,12 +349,22 @@ module StopTime::Models belongs_to :task has_one :customer, :through => :task + before_validation :round_start_end + # Returns the total amount of time, the duration, in hours (up to # 2 decimals only!). def hours_total ((self.end - self.start) / 1.hour).round(2) end + ######### + protected + + def round_start_end + self.start = round_time(self.start) + self.end = round_time(self.end) + end + ####### private