module FosdemRecorder class Duration getter start : Time getter stop : Time def initialize(@start, @stop) end def from_now() Duration.new(start: Time.local, stop: self.stop) end def value() duration = (self.stop - self.start).to_i end def past? Time.local > self.stop end def future? Time.local < self.start end def present? (Time.local >= self.start) && (Time.local <= self.stop) end def to_s() duration = self.value / 3600 duration_h = duration.to_i duration_m = ((duration - duration_h) * 60 + 1).to_i duration_str = sprintf("%02d:%02d:00", { duration_h, duration_m }) end end end