I'm currently using this method to calculate whether market is open. The problem is it doesn't handle EST vs EDT. Thoughts on adding something more robust to your gem?
class MarketHours
def self.open?(time = nil)
Time.use_zone('Eastern Time (US & Canada)') do
time ||= Time.current
return false if time.on_weekend?
market_open = Time.zone.local(time.year, time.month, time.day, 9, 30)
market_close = Time.zone.local(time.year, time.month, time.day, 16, 0)
time.between?(market_open, market_close)
end
end
end
Time zones are tricky. One problem with this is that Time.current is from Rails. I think a gem like this should not need to have Rails as a dependency.
I'm currently using this method to calculate whether market is open. The problem is it doesn't handle EST vs EDT. Thoughts on adding something more robust to your gem?