Module: Stardate::STime

Defined in:
lib/stardate.rb

Instance Method Summary collapse

Instance Method Details

#to_stardateObject



23
24
25
26
27
28
29
# File 'lib/stardate.rb', line 23

def to_stardate
  t1 = self.beginning_of_year
  t2 = self.beginning_of_day
  days = (t2 - t1) / 3600 / 24 # days passed since the beginning of the year
  seconds = self - t2          # seconds passed since the beginning of the day
  (BASE_DATE.stardate + ((self.year - BASE_DATE.year) + days / YEAR_DURATION + seconds / (YEAR_DURATION * 24 * 3600)) * 1000).round(1)
end