Module: ScheduleAttributes::TimeHelpers
- Defined in:
- lib/schedule_attributes/time_helpers.rb
Class Method Summary collapse
Class Method Details
.parse_in_zone(str) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/schedule_attributes/time_helpers.rb', line 3 def self.parse_in_zone(str) if Time.respond_to?(:zone) && Time.zone # Rails 4.1 removes Date.to_time_in_current_zone in favour of Date.in_time_zone if str.respond_to?(:in_time_zone) str.in_time_zone else str.is_a?(Date) ? str.to_time_in_current_zone : Time.zone.parse(str) end else str.is_a?(Time) ? str : Time.parse(str) end end |
.today ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/schedule_attributes/time_helpers.rb', line 16 def self.today if Time.respond_to?(:zone) && Time.zone # Rails 4.1 removes Date.to_time_in_current_zone in favour of Date.in_time_zone current_date = Date.current current_date.respond_to?(:in_time_zone) ? current_date.in_time_zone : current_date.to_time_in_current_zone else Date.today.to_time end end |