Module: RailsUtil::TimezoneHelper
- Defined in:
- lib/rails_util/timezone_helper.rb
Overview
RailsUtil::TimezoneHelper contains helper methods for converting a time between timezones.
Uses ActiveSupport::TimeZone timezone.tzinfo.name names (e.g., 'America/Chicago') to identify timezones.
Constant Summary collapse
- SECONDS_PER_HOUR =
3600
Class Method Summary collapse
-
.convert_timezone(time, to_timezone, from_timezone, **options) ⇒ Object
Converts a time between a
from_timezoneand ato_timezone.
Class Method Details
.convert_timezone(time, to_timezone, from_timezone, **options) ⇒ Object
Converts a time between a from_timezone and a to_timezone
16 17 18 19 20 |
# File 'lib/rails_util/timezone_helper.rb', line 16 def convert_timezone(time, to_timezone, from_timezone, **) date = .fetch(:date, time) utc_time = convert_to_utc(time, from_timezone, date) convert_from_utc(utc_time, to_timezone, date) end |