Module: Stardate::SFloat

Defined in:
lib/stardate.rb

Instance Method Summary collapse

Instance Method Details

#to_timeObject



33
34
35
36
37
38
39
40
# File 'lib/stardate.rb', line 33

def to_time
  y = 1000
  s = (y / YEAR_DURATION / 24 / 3600)
  stardate = self.round(1) - BASE_DATE.stardate
  year = (stardate / y).to_i
  seconds = ((stardate - (year * 1000)) / s).to_i
  Time.new(year + BASE_DATE.year) + seconds.seconds
end