ecoffee/lib/clock.rb

24 lines
505 B
Ruby

class Clock
EARTH_TO_EORZEA = 3600.0 / 175.0
EORZEA_TO_EARTH = 1.0 / EARTH_TO_EORZEA
def self.get_current_eorzea_time
to_eorzea_time(Time.now.utc)
end
def self.to_eorzea_time(earth_time)
et_ts = earth_time.to_i
new_ts = et_ts.abs * EARTH_TO_EORZEA
Time.at(new_ts)
end
def self.to_earth_time(ez_time)
ez_ts = ez_time.to_i
new_ts = (ez_ts * EORZEA_TO_EARTH).ceil
Time.at(new_ts)
end
def self.display_ez_time(ez_time)
ez_time.strftime("%H:%M")
end
end