Module: ImHungry::TzHelper
- Included in:
- FoodTruck
- Defined in:
- lib/im_hungry/tz_helper.rb
Instance Method Summary collapse
Instance Method Details
#current_time ⇒ Object
13 14 15 |
# File 'lib/im_hungry/tz_helper.rb', line 13 def current_time Time.now.getlocal(tz_offset) end |
#parse_time(time) ⇒ Object
3 4 5 |
# File 'lib/im_hungry/tz_helper.rb', line 3 def parse_time(time) Time.parse("#{time} #{tz_offset}") end |
#tz_offset ⇒ Object
7 8 9 10 11 |
# File 'lib/im_hungry/tz_helper.rb', line 7 def tz_offset timezone = TZInfo::Timezone.get(time_zone) offset_in_hours = timezone.current_period.utc_total_offset_rational.numerator format('%+.2d:00', offset_in_hours) end |