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
# File 'lib/schedule_attributes/time_helpers.rb', line 3

def self.parse_in_zone(str)
  if Time.respond_to?(:zone) && Time.zone
    return str.in_time_zone if str.is_a?(Time)
    str.is_a?(Date) ? str.to_time_in_current_zone : Time.zone.parse(str)
  else
    return str if str.is_a?(Time)
    Time.parse(str)
  end
end

.todayObject



13
14
15
16
17
18
19
# File 'lib/schedule_attributes/time_helpers.rb', line 13

def self.today
  if Time.respond_to?(:zone) && Time.zone
    Date.current.to_time_in_current_zone
  else
    Date.today.to_time
  end
end